思路:两个变量,一个变量存储数据之和,一个变量实现自增就行
do...while
cpp
int i, s;
i = 1;
s = 0;
do
{
s += 1;
i++;
} while (i <= 100);
cout << s << endl;
for
cpp
int i, j=0;
for (i = 1; i <= 100; i++)
{
j += 1;
}
cout << j << endl;
感觉至少条件是差不多的