以下のコードを使用しましたが、番号が間違っていて、講師は 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;
}