| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1398 人关注过本帖
标题:【求助】十万火急!!!!!!!!!(望有能者能予以解决)
只看楼主 加入收藏
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
 问题点数:0 回复次数:16 
【求助】十万火急!!!!!!!!!(望有能者能予以解决)
用类实现把八个同学的名字,学号,性别及五门课的成绩存入档案,当输入一个合法的学号时,即能查询出该同学的情况.
要求:1.查询的结果姓名,性别及五门课的成绩
        2.名字,学号,性别及五门课的成绩定义为学生类的私有成员.
(学号,学生名字,性别,课程名及成绩可以随便取.)

[[italic] 本帖最后由 lovely123 于 2007-11-29 15:21 编辑 [/italic]]
搜索更多相关主题的帖子: 能者 
2007-11-29 15:17
无缘今生
Rank: 2
等 级:新手上路
威 望:3
帖 子:523
专家分:7
注 册:2007-6-25
收藏
得分:0 
既然是用类,你那就定义一个类噻:
class Student
{
private:
    //学生的姓名,学号,性别
  //至于五门课的成绩,可以定义一个结构体grade
   //此处就写成:grade drades[5];   因为是五门课的成绩嘛
public:
   //写获取上面定义的各个属性的值的方法
  //还可以写一些你想要实现的功能
}

类定义好后,就可以在主函数里面声明类对象并调用各成员函数。
大概的思路就是这个样子,具体有代码还是自己动手吧。

时不再来!!!
2007-11-29 15:48
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
才初学,有点深奥哦!
2007-11-30 10:10
校园流氓
Rank: 1
来 自:江苏南京
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-11-30
收藏
得分:0 
唉!看来确实是个初学的人啊!
2007-11-30 10:24
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
那你帮下忙吧!
#include<iostream>
#include <string>
using namespace std;
class Student
{
private:
int num[8];
char name[8];
int age[8];
char sex[8];
int Category[a1][e8]=[8][5];
    void num()
    {cin>>"num1:">>06300685>>endl;
    cin>>"num2:">>06300686>>endl;
    cin>>"num3:">>06300687>>endl;
    cin>>"num4:">>06300688>>endl;
    cin>>"num5:">>06300689>>endl;
    cin>>"num6:">>06300690>>endl;
    cin>>"num7:">>06300691>>endl;
    cin>>"num8:">>06300692>>endl;
    };
    void name()
    {cin>>"name1:">>"譁鄵">>endl;
    cin>>"name2:">>"詉庅枏">>endl;
    cin>>"name3:">>"脦塍蓲">>endl;
    cin>>"name4:">>"虠轑鲻">>endl;
    cin>>"name5:">>"醟朙籩">>endl;
    cin>>"name6:">>"臡鼐孻">>endl;
    cin>>"name7:">>"恴赨">>endl;
    cin>>"name8:">>"絼躢閁鍀">>endl;
    };
    void age()
    {cin>>"age1:">>20>>endl;
    cin>>"age2:">>21>>endl;
    cin>>"age3:">>19>>endl;
    cin>>"age4:">>20>>endl;
    cin>>"age5:">>22>>endl;
    cin>>"age6:">>19>>endl;
    cin>>"age7:">>19>>endl;
    cin>>"age8:">>21>>endl;
    };
    void sex()
    {cin>>"sex1:">>"男">>endl;
    cin>>"sex2:">>"女">>endl;
    cin>>"sex3:">>"男">>endl;
    cin>>"sex4:">>"男">>endl;
    cin>>"sex5:">>"女">>endl;
    cin>>"sex6:">>"男">>endl;
    cin>>"sex7:">>"男">>endl;
    cin>>"sex8:">>"男">>endl;
    };
 void Category()
 int a1=88,b1=81,c1=75,d1=66,e1=53;
 int a2=92,b2=67,c2=89,d2=68,e2=70;
 int a3=53,b3=99,c3=76,d3=76,e3=80;
 int a4=78,b4=79,c4=75,d4=76,e4=99;
 int a5=60,b5=61,c5=54,d5=65,e5=90;
 int a6=88,b6=87,c6=89,d6=100,e6=86;
 int a7=64,b7=67,c7=30,d7=478,e7=62;
 int a8=46,b8=58,c8=21,d8=80,e8=66;
 };
 int main()



帮忙搞下错误和后面程序!
2007-11-30 12:12
ls120535021
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-11-8
收藏
得分:0 
还是自己学着写吧
不要过多依赖
2007-11-30 12:43
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
#include<iostream>
#include <string>
using namespace std;
class Student
{
private:
    int num1,num2,num3,mun4,num5,num6,num7,num8;
    string name1,name2,name3,name4,name5,name6,name7,mane8;
    int age1,ahe2,age3,age4,age5,age6,age7,age8;
    char sex1,sex2,sex3,sex4,sex5,sex6,sex7,sex8;
    int a1,a2,a3,a4,a5,a6,a7,a8;
    int b1,b2,b3,b4,b5,b6,b7,b8;
    int c1,c2,c3,c4,c5,c6,c7,c8;
    int d1,d2,d3,d4,d5,d6,d7,d8;
    int e1,e2,e3,e4,e5,e6,e7,e8;
    void num()
    {cin>>"num1:">>"06300685">>endl;
    cin>>"num2:">>"06300686">>endl;
    cin>>"num3:">>"06300687">>endl;
    cin>>"num4:">>"06300688">>endl;
    cin>>"num5:">>"06300689">>endl;
    cin>>"num6:">>"06300690">>endl;
    cin>>"num7:">>"06300691">>endl;
    cin>>"num8:">>"06300692">>endl;
    };
    void name()
    {cin>>"name1:">>"譁鄵">>endl;
    cin>>"name2:">>"詉庅枏">>endl;
    cin>>"name3:">>"脦塍蓲">>endl;
    cin>>"name4:">>"虠轑鲻">>endl;
    cin>>"name5:">>"醟朙籩">>endl;
    cin>>"name6:">>"臡鼐孻">>endl;
    cin>>"name7:">>"恴赨">>endl;
    cin>>"name8:">>"絼躢閁鍀">>endl;
    };
    void age()
    {cin>>"age1:">>20>>endl;
    cin>>"age2:">>21>>endl;
    cin>>"age3:">>19>>endl;
    cin>>"age4:">>20>>endl;
    cin>>"age5:">>22>>endl;
    cin>>"age6:">>19>>endl;
    cin>>"age7:">>19>>endl;
    cin>>"age8:">>21>>endl;
    };
    void sex()
    {cin>>"sex1:">>"男">>endl;
    cin>>"sex2:">>"女">>endl;
    cin>>"sex3:">>"男">>endl;
    cin>>"sex4:">>"男">>endl;
    cin>>"sex5:">>"女">>endl;
    cin>>"sex6:">>"男">>endl;
    cin>>"sex7:">>"男">>endl;
    cin>>"sex8:">>"男">>endl;
    };
 int a1=88,b1=81,c1=75,d1=66,e1=53;
 int a2=92,b2=67,c2=89,d2=68,e2=70;
 int a3=53,b3=99,c3=76,d3=76,e3=80;
 int a4=78,b4=79,c4=75,d4=76,e4=99;
 int a5=60,b5=61,c5=54,d5=65,e5=90;
 int a6=88,b6=87,c6=89,d6=100,e6=86;
 int a7=64,b7=67,c7=30,d7=478,e7=62;
 int a8=46,b8=58,c8=21,d8=80,e8=66;
 };
 int main()
 {cout<<"请输入学号:"<<endl;
int s;
cin>>s;
if(s=num1)
{cout<<num1<<" "<<name1<<" "<<sex1<<" "<<a1+b1+c1+d1+e1<<endl;}
if(s=num2)
{cout<<num2<<" "<<name2<<" "<<sex2<<" "<<a2+b2+c2+d2+e2<<endl;}
if(s=num3)
{cout<<num3<<" "<<name3<<" "<<sex3<<" "<<a3+b3+c3+d3+e3<<endl;}
if(s=num4)
{cout<<num4<<" "<<name4<<" "<<sex4<<" "<<a4+b4+c4+d4+e4<<endl;}
if(s=num5)
{cout<<num5<<" "<<name5<<" "<<sex5<<" "<<a5+b5+c5+d5+e5<<endl;}
if(s=num6)
{cout<<num6<<" "<<name6<<" "<<sex6<<" "<<a6+b6+c6+d6+e6<<endl;}
if(s=num7)
{cout<<num7<<" "<<name7<<" "<<sex7<<" "<<a7+b7+c7+d7+e7<<endl;}
if(s=num8)
{cout<<num8<<" "<<name8<<" "<<sex8<<" "<<a8+b8+c8+d8+e8<<endl;}

else cout<<"学号错误:"<<endl;}
 return 0;
 }


错误比行数还多~~~~~~~!!!!!!
2007-11-30 12:58
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
还有一个错误,帮忙改下
#include<iostream>
#include <string>
using namespace std;
class Student
{
private:
    int num1,num2,num3,mun4,num5,num6,num7,num8;
    string name1,name2,name3,name4,name5,name6,name7,mane8;
    int age1,ahe2,age3,age4,age5,age6,age7,age8;
    char sex1,sex2,sex3,sex4,sex5,sex6,sex7,sex8;
    int a1,a2,a3,a4,a5,a6,a7,a8;
    int b1,b2,b3,b4,b5,b6,b7,b8;
    int c1,c2,c3,c4,c5,c6,c7,c8;
    int d1,d2,d3,d4,d5,d6,d7,d8;
    int e1,e2,e3,e4,e5,e6,e7,e8;
    void num()
    {cin>>"num1:">>"06300685">>endl;
    cin>>"num2:">>"06300686">>endl;
    cin>>"num3:">>"06300687">>endl;
    cin>>"num4:">>"06300688">>endl;
    cin>>"num5:">>"06300689">>endl;
    cin>>"num6:">>"06300690">>endl;
    cin>>"num7:">>"06300691">>endl;
    cin>>"num8:">>"06300692">>endl;
    };
    void name()
    {cin>>"name1:">>"譁鄵">>endl;
    cin>>"name2:">>"詉庅枏">>endl;
    cin>>"name3:">>"脦塍蓲">>endl;
    cin>>"name4:">>"虠轑鲻">>endl;
    cin>>"name5:">>"醟朙籩">>endl;
    cin>>"name6:">>"臡鼐孻">>endl;
    cin>>"name7:">>"恴赨">>endl;
    cin>>"name8:">>"絼躢閁鍀">>endl;
    };
    void age()
    {cin>>"age1:">>20>>endl;
    cin>>"age2:">>21>>endl;
    cin>>"age3:">>19>>endl;
    cin>>"age4:">>20>>endl;
    cin>>"age5:">>22>>endl;
    cin>>"age6:">>19>>endl;
    cin>>"age7:">>19>>endl;
    cin>>"age8:">>21>>endl;
    };
    void sex()
    {cin>>"sex1:">>"男">>endl;
    cin>>"sex2:">>"女">>endl;
    cin>>"sex3:">>"男">>endl;
    cin>>"sex4:">>"男">>endl;
    cin>>"sex5:">>"女">>endl;
    cin>>"sex6:">>"男">>endl;
    cin>>"sex7:">>"男">>endl;
    cin>>"sex8:">>"男">>endl;
    };
    void a()
    {cin>>"a1">>75>>endl;
    cin>>"a2">>100>>endl;
    cin>>"a3">>66>>endl;
    cin>>"a4">>84>>endl;
    cin>>"a5">>60>>endl;
    cin>>"a6">>86>>endl;
    cin>>"a7">>97>>endl;
    cin>>"a8">>58>>endl;
    };

    void b()
    {cin>>"b1"=93>>endl;
    cin>>"b2"=65>>endl;
    cin>>"b3"=69>>endl;
    cin>>"b4"=89>>endl;
    cin>>"b5"=88>>endl;
    cin>>"b6"=90>>endl;
    cin>>"b7"=94>>endl;
    cin>>"b8"=68>>endl;
    };

    void c()
    {cin>>"c1"=79>>endl;
    cin>>"c2"=68>>endl;
    cin>>"c3"=95>>endl;
    cin>>"c4"=56>>endl;
    cin>>"c5"=40>>endl;
    cin>>"c6"=76>>endl;
    cin>>"c7"=65>>endl;
    cin>>"c8"=60>>endl;
    };

    void d()
    {cin>>"d1"=87>>endl;
    cin>>"d2"=100>>endl;
    cin>>"d3"=75>>endl;
    cin>>"d4"=35>>endl;
    cin>>"d5"=55>>endl;
    cin>>"d6"=80>>endl;
    cin>>"d7"=87>>endl;
    cin>>"d8"=61>>endl;
    };

    void e()
    {cin>>"e1"=30>>endl;
    cin>>"e2"=72>>endl;
    cin>>"e3"=69>>endl;
    cin>>"e4"=88>>endl;
    cin>>"e5"=73>>endl;
    cin>>"e61"=99>>endl;
    cin>>"e7"=100>>endl;
    cin>>"e8"=57>>endl;
    };

  int main()

 {cout<<"请输入学号:"<<endl;
int s;
cin>>s;
if(s=num1)
{cout<<num1<<" "<<name1<<" "<<sex1<<" "<<a1+b1+c1+d1+e1<<endl;}
if(s=num2)
{cout<<num2<<" "<<name2<<" "<<sex2<<" "<<a2+b2+c2+d2+e2<<endl;}
if(s=num3)
{cout<<num3<<" "<<name3<<" "<<sex3<<" "<<a3+b3+c3+d3+e3<<endl;}
if(s=num4)
{cout<<num4<<" "<<name4<<" "<<sex4<<" "<<a4+b4+c4+d4+e4<<endl;}
if(s=num5)
{cout<<num5<<" "<<name5<<" "<<sex5<<" "<<a5+b5+c5+d5+e5<<endl;}
if(s=num6)
{cout<<num6<<" "<<name6<<" "<<sex6<<" "<<a6+b6+c6+d6+e6<<endl;}
if(s=num7)
{cout<<num7<<" "<<name7<<" "<<sex7<<" "<<a7+b7+c7+d7+e7<<endl;}
if(s=num8)
{cout<<num8<<" "<<name8<<" "<<sex8<<" "<<a8+b8+c8+d8+e8<<endl;}

else cout<<"学号错误:"<<endl;}
 return 0;
 }
2007-11-30 14:42
funb0y
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-9-29
收藏
得分:0 
~大哥。这样的题~很好搞啊。。。
汗。
2007-11-30 14:59
duccdd
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2007-10-25
收藏
得分:0 
汗一下LZ cin 的用法
2007-11-30 17:29
快速回复:【求助】十万火急!!!!!!!!!(望有能者能予以解决)
数据加载中...
 
   



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

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