【发布时间】:2016-10-14 08:52:11
【问题描述】:
我想显示如下输出:
Count Input Total
----- ------ -----
1 2 2
2 4 6
3 6 12
4 8 20
Average : 5
这是我的尝试:
int count=1,num,total=0;
cout<<"Count Input Total"<<endl;
cout<<"----- ----- -----"<<"\n";
while(count<=4)
{
cout<<count<<"\t";
cin>>num;
total=total+num;
cout<<"\t\t"
<<total<<endl;
count++;
}
cout<<"Average : "
<<total/4;
return 0;
}
但结果是这样的:
Count Input Total
----- ----- -----
1 2
2
2 4
6
3 6
12
4 8
20
Average : 5
--------------------------------
Process exited after 5.785 seconds with return value 0
Press any key to continue . . .
【问题讨论】: