返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {  
  6.     int a=0,n=0;
  7.     cout<<"請輸入一整數: ";
  8.     cin>>a;
  9.         
  10.     for(int i=0; i<=1000; i=i+a)
  11.     {
  12.         n=n+i;
  13.         
  14.     }
  15.     cout<<"1~1000所有"<<a<<"的倍數總和為: "<<n<<endl;
  16.     system("pause");
  17.     return 0;   
  18. }
複製代碼

TOP

返回列表