17 lines
251 B
C++
17 lines
251 B
C++
|
#include <iostream>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int i = 1, total = 0;
|
||
|
while (i <= 100)
|
||
|
{
|
||
|
if (i % 3 == 0)
|
||
|
total += i;
|
||
|
i++;
|
||
|
}
|
||
|
|
||
|
cout << "1~100的3的倍数和为: " << total << endl;
|
||
|
return 0;
|
||
|
}
|