| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 385 人关注过本帖
标题:新人求助、、
取消只看楼主 加入收藏
zl940123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-11
收藏
 问题点数:0 回复次数:1 
新人求助、、
#include<iostream>

#define N 100

using namespace std;

class Student

{

public:

       Student(int n,char* nam,char s);

       void SetName(char* n)
       {
           strcpy(name,n);
       }

    int GetNo()
    {
        return no;
    }

       string GetName()
       {
           return name;
       }

       char GetSex()
       {
           return sex;
       }

private:

       int no;

       char name[16];

       char sex;

};


Student::Student(int n,char* nam,char s)

{

       no=n;

       strcpy(name,nam);

       sex=s;

}


  

int main()

{

    Student *stu[N];

    int num=0;

       int y,m,d,no;

    char sex;

    char name[16];
    int i,choose,choose1=1;

   

       cout<<"\n\t\t======================================="<<endl;

    cout<<"\t\t1:录入 2:显示 3:修改 0:退出"<<endl;

    cout<<"\n输入您要进行的操作:";

    cin>>choose;

      

       while(choose!=0)

       {

              switch(choose)

              {

         case 1:

                      cout<<"请按学号、姓名、性别顺序输入学生信息"<<endl;

                   cin>>no>>name>>sex;

                   cin>>y>>m>>d;

                   stu[num++] = new Student(no,name,sex);

                   break;

            case 2:

                  cout<<"学号、姓名、性别"<<endl;

                   for(i=0;i<num;i++)

                      cout<<(*stu[i]).GetNo()<<"  "<<(*stu[i]).GetName()<<"  "<<(*stu[i]).GetSex()<<endl;

                break;

           case 3:

                     cout<<"输入学号:";

                  cin>>no;

                  for(i=0;i<num;i++)

                     {

                            if(no==(*stu[i]).GetNo())

                            {

                                   cout<<"\n\n1:名字修改 "<<endl;

                                cout<<"选择您要进行的修改方式:"<<endl;

                                cin>>choose1;

                                switch(choose1)

                                   {

                                   case 1:

                                          cout<<"输入姓名:";

                                       cin>>name;

                                       (*stu[i]).SetName(name);

                                       break;
                                }
                                break;
                            }
                  }

                               break;
 
                  }

              cout<<"\n\t\t======================================="<<endl;

        cout<<"\t\t1:录入 2:显示 3:修改 0:退出"<<endl;

        cout<<"\n输入您要进行的操作:";

        cin>>choose;

       }


    return 0;
}


似乎录入后成了死循环,求大神解答
搜索更多相关主题的帖子: namespace void private include public 
2013-04-11 12:48
zl940123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-11
收藏
得分:0 
  怎么弄啊
2013-04-11 12:49
快速回复:新人求助、、
数据加载中...
 
   



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

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