C/C++の宿題片付けます 134代目
■ このスレッドは過去ログ倉庫に格納されています
0830デフォルトの名無しさん
2010/03/03(水) 20:11:21#include <fstream>
// ここから始まる...
#include <iostream>
using namespace std;
int main()
{
ofstream of("prog.cpp");
int i, start, end;
cout << "初めの数字を入力せよ" << endl;
cin >> start;
cout << "終わりの数字を入力せよ" << endl;
cin >> end;
of << "#include <iostream>" << endl;
of << "using namespace std;" << endl;
of << endl;
of << "int main()" << endl;
of << "{" << endl;
of << "\tlong int sum = " << start;
for (i = start + 1; i <= end; ++i)
of << " + " << i;
of << ";" << endl;
of << "\tcout << " << start << " << \"から\" << " << end;
of << " << \"までの合計は\" << sum << \"です。\" << endl;" << endl;
of << "\treturn 0;" << endl;
of << "}" << endl;
of.close();
system("g++ prog.cpp -o prog");
system("./prog");
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています