|
#include<iostream.h>
int main()
{
struct Student
{
char name[10];
float total;
}s[100];
int k,max,min;
float x;
for(k=0;k<100;k++)
{
x= s[k].total;
cin>>x>>s[k].name>>endl;
}
max=min=0;
for(k=1;k<100;k++)
{
if(s[max].total<s[k].total)
max=k;
if(s[max].total>s[k].total)
min=k;}
cout<<"MAX"<<s[max].name<<","<<s[max].total<<endl;
cout<<"MIN"<<s[min].name<<","<<s[min].total<<endl;
}
还有这个:
#include<iostream.h>
#include <string.h>
struct Person
{
char name[20];
int number;
char addr[30];
};
Person per[5]={{"Wang Ming",2749703,"103 Beijing Road"},
{
"Li Hong",2719838,"130 Nanjing Road"},
{
"Guo Dong",2738339,"120 Xi'an Road"},
{
"Zhong Li",2726225,"117 Zhongshan Road"},
{
"Jing Zhuang",2149719,"138 Jinan road"}};
int main()
{
int i;
char per_name[20];
if(i>=0&&i<5)
{
cin >>"input per_name:" >>per_name>>endl;
if(strcmp(per_name,per[i].name)==0)
cout<<per[i].name<<" "<<per[i].number<<" "<<per[i].addr<<endl;}
else
{
cout<<"there is no result"<<endl;
}
return 0;
} |
|