| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 387 人关注过本帖
标题:请找出错误
只看楼主 加入收藏
rogergao123
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-6-11
收藏
 问题点数:0 回复次数:1 
请找出错误
#include<iostream>
#include<string>
using namespace std;
struct Student{
int num;
string name;
char sex;
float score;
}
void main()
{

cout<<"num is"<<endl;
cout<<"name is"<<endl;
cout<<"sex is"<<endl;
cout<<"score is"<<endl;
Student stu;
Student *p=&stu;
cin>>(*p).num>>(*p).name>>(*p).sex>>(*p).score;
cout<<(*p).num<<" "<<(*P).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;




#define NULL 0
#include<iostream>
using namespace std;
struct Student{

long num;
float score;
struct Student *next;
}
int main()
{
Student a,b,c,*head,*p;
a.num=31001;a.score=39.5;
b.num=31003;b.score=90;
c.num=31007;c.score=85;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{cout<<p->num<<" "<<p->score<<endl;}
p=p->next;
while
p!=NULL;
return 0;
}
}

我是菜鸟,请问这两则程序哪里错了
搜索更多相关主题的帖子: include 
2007-09-19 08:43
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 

#include <iostream>
#include <string.h>

using namespace std;

typedef struct Student{
int num;
string name;
char sex[12];
float score;
} Student;

int main()
{
Student stu;
cout<<"num is ";
cin>>stu.num;
cout<<"name is ";
char str[256];
cin>>str;
stu.name=str;
cout<<"sex is ";
cin>>stu.sex;
cout<<"score is ";
cin>>stu.score;

cout<<stu.num<<"\t"<<stu.name.c_str()<<"\t"<<stu.sex<<"\t"<<stu.score<<endl;
return 0;
}


#define NULL 0
#include<iostream>
using namespace std;

typedef struct Student
{
long num;
float score;
Student *next;
} Student;

int main()
{
Student a,b,c,*head,*p;
a.num=31001;a.score=39.5;
b.num=31003;b.score=90;
c.num=31007;c.score=85;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{
cout<<p->num<<" "<<p->score<<endl;
}
while ((p=p->next) != NULL);

return 0;
}


=×&D o I p R e E n C g T l X&×=
2007-09-19 12:15
快速回复:请找出错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018775 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved