其实这个题和以前的那个复数相加是差不多的,主要是练习字符串流(这个题其实是练习模板,因为我模板并不是很会,所以过些时间再补充一下模板是怎么做的吧)
#include <iostream>
#include <cmath>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int ty;
cin>>ty;
while(ty!=-1)
{
if(ty==1)//根据题意,依照不同的ty,进行不同的找最大值
//说实话这个题我没有读题,只是看了一下样例,但是这样是一个很不好的习惯
{
int n,m=-1e9;//设置m为最小的一个数,这样比较保险
while(cin>>n&&n!=0)
{
m=max(n,m);
}
cout<<m<<endl;
}
if(ty==2)
{
double n,m=-1e9;
while(cin>>n&&n!=0)
{
m=max(n,m);
}
cout<<m<<endl;
}
if(ty==3)
{
int a,b,c,s1=0;
int d,e,g,s2=0;
string s;
getline(cin,s);//因为这个字符串中会有空格,所以得用getline
stringstream ss(s);
// cout<<"sdsd"<<endl;
while(ss>>a>&g