原始问题:
"Bessie的手机号码复制粘贴游戏"
25945;?#20013;把手机号码复制了三次,然后用【粘贴】功能把它粘贴到一个文本文件中。请你写一个c++程序,从键盘上输入Bessie的手机号码,然后把它复制三次,并把这三个数字连在一起,写入一个文件中。
include
include
using namespace std;
int main()
{
string num, new_num;
cout << "Please enter Bessie's phone number: " << endl; // prompt user to enter phone number of Bessie
cin >> num; // read the number from keyboard
for (int i = 0; i < 3 ; i++) { // copy the input three times and concatenate them into one string.
new_num += num + ' ' ; // add a space between each copy of the input number.
}
ofstream outputFile("output.txt"); // create an output file and write the result into it.
outputFile << new_num << endl ; // write the concatenated string into the file.
return 0; }
Prev:用实例说明理性决策、非理性决策和行为决策