標題:
2025/2/7 課堂重點(昀杰)
[打印本頁]
作者:
郭竑志
時間:
2025-2-7 18:55
標題:
2025/2/7 課堂重點(昀杰)
本帖最後由 郭竑志 於 2025-2-7 19:41 編輯
[課程重點]
複習上次上課內容
字串處理 (一)
字串處理 (二) - 字串輸入 1
字串處理 (三) - 字串輸入 2
字串處理 (五) - 英文大小寫轉換
[今日作業]
函式的建立與執行 (四)
字串處理 (四) - 字串中第n個字母為何
作者:
郭竑志
時間:
2025-2-7 18:55
1、寫一函式,函式名稱為:basic01;接收三個浮點數參數,三個浮點數相乘後回傳浮點數結果。
作者:
郭竑志
時間:
2025-2-7 18:56
寫一函式,函式名稱為:basic04;接收一整數參數,然後在畫面上畫出倒三角形。
例如:輸入5,則輸出畫面為:
*****
****
***
**
*
作者:
郭竑志
時間:
2025-2-7 18:56
寫一函式,函式名稱為:basic08;接收兩個字串參數,然後會將兩個字串接起來後,回傳這個新的字串。
作者:
陳昀杰
時間:
2025-2-7 19:13
#include<bits/stdc++.h>
using namespace std;
float basic01(float x,float y,float z)
{
return x*y*z ;
}
int main()
{
float a,b,c;
cin>>a>>b>>c;
cout<<basic01(a,b,c);
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-2-7 19:14
#include<bits/stdc++.h>
using namespace std;
void basic04(int x)
{
for(int i=x;i>0;i--)
{
for(int k=i;k>0;k--)
{
cout<<"*";
}
cout<<endl;
}
return ;
}
int main()
{
int a;
cin>>a;
basic02(a);
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-2-7 19:15
#include<bits/stdc++.h>
using namespace std;
string basic08(string x,string y)
{
return x+y;
}
int main()
{
string a,b;
cin>>a>>b;
cout<<basic08(a,b);
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-2-7 19:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string str1="Good morning!";
char str2[14]="Good morning!";
cout<<str1<<endl;
cout<<str2<<endl;
cout<<str1[0]<<endl;
cout<<str2[0]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-2-7 19:33
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
string str;
getline(cin,str);
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-2-7 20:00
#include <iostream>
#include <string>
#include <algorithm> // For std::transform
using namespace std;
int main() {
string str;
cout << "輸入一字串: ";
getline(cin, str);
// Convert to uppercase
transform(str.begin(), str.end(), str.begin(), ::toupper);
cout << "轉為大寫: " << str << endl;
// Convert to lowercase
transform(str.begin(), str.end(), str.begin(), ::tolower);
cout << "轉為小寫: " << str << endl;
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-3-7 18:48
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
getline(cin,str);
int n;
cin>>n;
cout<<str[n-1];
}
複製代碼
作者:
陳昀杰
時間:
2025-3-7 18:49
#include<bits/stdc++.h>
using namespace std;
void a(string x,int y)
{
for(int i;i<y;i++)
{
cout<<x<<endl;
}
return ;
}
int main()
{
int y;
string x;
cin>>x>>y;
a(x,y);
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2