c++程序設計——實驗1

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;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章