新微赢技术网
标题:
大哥大姐帮忙把这个程序整一下,它怎麽调试通不过啊
[打印本页]
作者:
流星
时间:
2009-11-4 00:50
标题:
大哥大姐帮忙把这个程序整一下,它怎麽调试通不过啊
#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;
}
作者:
帅精灵
时间:
2009-11-4 00:50
程序代码:
#include<iostream>
using namespace std;
int main()
{
const int NUM = 10;
struct Student
{
float total;
char name[10];
}s[NUM];
int k, max, min;
float x;
for(k=0; k<NUM; k++)
{
cin>>s[k].total;
cin>>s[k].name;
}
max = min = 0;
for(k=1; k<NUM; k++)
{
if(s[max].total < s[k].total)
{
max=k;
}//end if
if(s[max].total > s[k].total)
{
min=k;
}//end if
}//end for
cout<<"MAX "<<s[max].name<<", "<<s[max].total<<endl;
cout<<"MIN "<<s[min].name<<", "<<s[min].total<<endl;
return 0;
}
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2