| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 895 人关注过本帖
标题:一个恶心的问题
只看楼主 加入收藏
diandianlian
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-10-19
收藏
 问题点数:0 回复次数:26 
一个恶心的问题

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

/* struct student
{
char name[30];
int number ,score;
};*/

void main()
{
/*char fileName[30];
cout<<"请输入文件名:"<<endl;
cin>>fileName;
fstream stu(fileName,ios::out|ios::in|ios::binary);
/*if(!stu)

{
cerr<<"文件打开失败!"<<endl;
abort();

}

student st;
student * ps=&st;
int counter1=0;
int counter2=0;
double total=0;
do
{

cout<<"请输入学号,姓名,分数\n?";

cin>>ps->number>>ps->name>>ps->score;
if(cin.get()==EOF)
break;
counter1++;

total+=ps->score;

stu.write((char*)ps,sizeof(student));
}while(1);

cout<<"平均分为:"<<total/counter1<<endl;
stu.seekg(0);
for(int i=0;i<counter1;i++)

{

stu.read((char*)ps,sizeof(student));
cout<<"学号为:"<<ps->number<<ends<<"姓名为:"<<ps->name<<ends<<"分数为:"<<ps->score<<endl;

}

char name2[30];
do
{
cout<<"请输入你想查询学生的姓名(noname结束):"<<endl;
cin>>name2;
/*if(!strcmp(name2,"noname"))
{
cout<<"退出查询!"<<endl;
return;
}
else
{
stu.seekg(0);

for(int i=0;i<counter1;i++)
{
stu.read((char*)ps,sizeof(student));
if(!(strcmp(ps->name,name2)))
{
cout<<"学号为:"<<ps->number<<ends<<"姓名为:"<<ps->name<<ends<<"分数为:"<<ps->score<<endl;
break;
}
else
counter2++;

}
if(counter2==counter1)
cout<<"没有你想查询的学生!"<<endl;
}*/
}while(1);




/* for(int pass=1;pass<counter1;pass++)
{

for(j=0;j<counter1-pass;j++)
{
if(pt[i]->score>pt[i+1]->scor)
{
temp=pt[i]->score;
pt[i]->score=pt[i+1]->scor;
pt[i+1]->scor=temp;
work=0;
}
}
if(work)break;

}
}
for(i=0;i<counter1;i++)
{
stu.seekg(0);
stu.read((char*)pt[i],sizeof(student));
}*/

}

各位帮忙看看这个程序的运行错误:运行到cin时不能输入。

搜索更多相关主题的帖子: 恶心 
2007-10-19 17:41
稀饭老鼠
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-10-19
收藏
得分:0 

似乎很高深!不会

2007-10-19 18:09
jojo_fjl
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-10-19
收藏
得分:0 
......
2007-10-19 18:12
guobingyu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-9-12
收藏
得分:0 
cin>>ps->number>>ps->name>>ps->score;
是他的问题吗???????
2007-10-19 18:20
yoapple
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-10-13
收藏
得分:0 

太多错误:
1 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\iostream.h:31, from main.cpp In file included from D:/Program Files/Dev/Dev-Cpp/include/c++/3.3.1/backward/iostream.h:31, from main.cpp
1 D:\Program Files\Dev\Dev-Cpp\main.cpp from main.cpp
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
2 D:\Program Files\Dev\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.


2007-10-19 19:29
loveling
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-10-19
收藏
得分:0 

我的邮箱:loveyoulizhao@
2007-10-19 19:33
diandianlian
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-10-19
收藏
得分:0 

是那个查询里的cin>>name2!

2007-10-19 21:34
ly5771
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-10-15
收藏
得分:0 
晕忽的
2007-10-20 12:28
枫之恋
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-10-13
收藏
得分:0 
看不懂哦,调用了那么多函数库!

我有点菜,但我很努力!!!
2007-10-20 12:42
tracy君帝
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-10-19
收藏
得分:0 

吆,卡卡西......有点小郁闷.......尽管每次网到鱼的不过是一个网眼,但要想捕到鱼,就必须要编织一张网…
2007-10-20 12:51
快速回复:一个恶心的问题
数据加载中...
 
   



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

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