標題:
字串處理 (八) - 將字串轉換為ASCII碼
[打印本頁]
作者:
方浩葦
時間:
2024-10-5 13:43
標題:
字串處理 (八) - 將字串轉換為ASCII碼
本帖最後由 方浩葦 於 2024-10-5 18:13 編輯
提示: int(字元) --> ASCII碼
本帖隱藏的內容需要回復才可以瀏覽
作者:
鄭豊翰
時間:
2024-11-30 10:24
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
char str[100];
int sum=0;
cout << "請輸入一字串: ";
cin.getline(str, 100);
cout<<"Your 字串 translataed into ASCII is: "<<endl;
for (int i = 0; str[i] != '\0'; i++){
cout<< int(str[i])<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉冠毅
時間:
2024-12-7 14:40
#include<iostream>
#include<cstdlib>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
string str;
cout<<"輸入字串: ";
getline(cin,str);
for(int i=0;i<str.size();i++){
cout<<int(str[i])<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2025-3-7 19:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string str;
cin>>str;
for(int i=0;i<str.size();i++)
{
cout<<str[i]+0<<endl;
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2