// C4_1.cpp : Defines the entry point for the console application. // for 迴圈應用 #include "stdafx.h" #include using namespace std; int main(int argc, char* argv[]) { int k = 0, sum = 0; int max = 10; cout << endl << "請輸入一整數值 : "; cin >> max; for(k = 1; k <= max; k++) // for 迴圈宣告 sum += k; // 迴圈指令 cout << endl << "1 至 "<< max << " 整數加總 = " << sum << endl << endl << "k 值 = " << k << endl; return 0; return 0; }