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

TOP

返回列表