#include<iostream>
using namespace std;
int main()
{
   int a,b=0,c;
   cout<<"請輸入要累加的底數:";
   cin>>a;
   for(c=1;c<=a;c++)           //for(初始值設定;條件判斷式;參數改變式)
      b+=c;
      cout<<"總和="<<b<<endl;
      system("PAUSE");
      return 0;
    }

 

結果輸出:

請輸入要累加的底數:66
總和=2211
請按任意鍵繼續 . . .

arrow
arrow
    全站熱搜

    霄狼一哥 發表在 痞客邦 留言(0) 人氣()