#include using namespace std; //ex1.10回"大事なことだから何度も言います。"と改行付きで表示 int main() { int count = 0; while (count < 10) { //繰り返す処理 cout << count << ":" << "大事なことだから何度も言います" << endl; //countを増やす count = count + 1; } return 0; } #include using namespace std; //ex2.cinで入力した回数(正の整数)"hello, world"を表示 int main() { int count = 0; int val;//val回実行する! cout << "正の整数を入力:"; cin >> val; if(val < 0) { //エラー処理 cout << "input error" << endl; return -1; } else { while (count < val) { //繰り返す処理 cout << count << "回目:" << "hello,world" << endl; //countを増やす count = count + 1; } } return 0; } #include using namespace std; //ex3.1~100の総和(summation)を表示する処理 int main() { int count = 1; int sum = 0; while (count <= 100) { cout << count << endl; sum = sum + count; count = count + 1; } cout << "1~100の総和は" << sum << endl; return 0; }