设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 1939|回复: 1
打印 上一主题 下一主题

请找出错误

[复制链接]
跳转到指定楼层
1#
发表于 2009-11-3 01:13:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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;
}
}

我是菜鸟,请问这两则程序哪里错了
2#
发表于 2009-11-3 01:13:07 | 只看该作者
#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;
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 04:42 , Processed in 0.101904 second(s), 9 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表