1.輸入一攝氏溫度,輸出顯示所轉換的華氏溫度。
(提示:攝氏溫度=(華氏溫度-32)×5/9)
#include <iostream>
using namespace std;
int main(){
double s = 0.0;
while(1){
cout << "請輸入華氏溫度:";
cin >> s;
cout << " 轉化結果爲:" \
<< s << "℃" << " = " \
<< ((9.0*s/5)+32) \
<< "℉" << "。" << endl;
}
return 0;
}
2.畫出一頭威武雄壯的雄獅。
,%%%%%%
,%%/\%%%%/\%
,%%%\c "" J/%%%
%. %%%%/ o o \%%%
`%%. %%%% _ |%%
`%% `%%%%(__Y__)%
// ;%%%%`\-/%%%'
(( / `%%%%%%%'
\\ .' |
\\ / \ | |
\\/ ) | |
\ /_ | |__
(___________)))))))
#include <iostream>
using namespace std;
int main(){
cout << " ,%%%%%%" << endl;
cout << " ,%%/\%%%%/\%" << endl;
cout << " ,%%%\c \"\" J/%%%" << endl;//cout << " ,%%%\c "" J/%%%" << endl;
cout << " %. %%%%/ o o \%%%" << endl;
cout << " `%%. %%%% _ |%%" << endl;
cout << " `%% `%%%%(__Y__)%" << endl;
cout << " // ;%%%%`\-/%%%'" << endl;
cout << " // ;%%%%`\-/%%%'" << endl;
cout << " (( / `%%%%%%%'" << endl;
cout << " \\\\ .' |" << endl;//字符“\”對應的轉義字符爲"\\"
cout << " \\\\ / \ | |" << endl;
cout << " \\\\/ ) | |" << endl;
cout << " \\\ /_ | |__" << endl;
cout << " (___________)))))))" << endl;
return 0;
}