标签:数字 iostream 个数 cout bsp turn clu str names
此题,无需输入N,只是简单的输入是个数字,
刚开始的时候,
WA的代码:
#include<iostream>
using namespace std;
int main()
{
int tem;
int max=0;
while(1)
{
for (int i=0;i<10;i++)
{
cin>>tem;
if (max<tem) max=tem;
}
cout<<"max="<<max<<endl;
}
return 0;
}
while(1)是超出时间限制的问题
换成while(cin>>max)的就可以了。
AC的代码:
#include<iostream>
using namespace std;
int main()
{
int tem;
int max=0;
while(cin>>max)
{
for (int i=1;i<10;i++)
{
cin>>tem;
if (max<tem) max=tem;
}
cout<<"max="<<max<<endl;
}
return 0;
}
题目1046:求最大值---------------此题较为水,但是仍然有需要注意的地方,原来可以这么输入!!!!
标签:数字 iostream 个数 cout bsp turn clu str names
原文地址:http://www.cnblogs.com/jianrenguo/p/6457876.html