我使用了下面的代码,但我的数字不正确,我的教练宁愿我使用 for 循环。它还需要打印出来:
“n”到“n”的和是“”(1到1的和是1)“n”到“n”的和是“”(1到2的和是3)
我试过使用 for 循环,但似乎无法正确打印出上面的代码。我迷路了!
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    const int NUM_LOOPS = 50;
    int count = 0;
    while (count < NUM_LOOPS)
    {
        cout << "Sum of 1 through " << count << " is " << (count * (++count)) / 2 << endl;
    }
    system("pause.exe");
    return 0;
}