zhleven吧 关注:7贴子:1,298
  • 0回复贴,共1
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
if (cin.peek()=='\n')
{
cout<<'0'<<','<<'0';
system("pause");
return 0;
}
int a[128];
int num;
int count=0;
while(cin>>num)
{
a[count++]=num;
char b;
cin.get(b);
if (b!=',')
break;
}
int max1,max2;
if (count==1)
cout<<a[0]<<","<<a[0];
else
{max1=a[0];
max2=a[1];
for (int i=0;i<count;i++)
{
if (a[i]>max1)
{
max2=max1;
max1=a[i];
}
else if(a[i]>max2&&a[i]<max1)
max2=a[i];
}
cout<<max1<<","<<max2;
}
system("pause");
return 0;
}


IP属地:江苏1楼2015-09-12 15:21回复