| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:c++小程序问题求教?
只看楼主 加入收藏
chenbofeng20
Rank: 4
来 自:陕西 宝鸡
等 级:业余侠客
威 望:3
帖 子:113
专家分:274
注 册:2009-9-18
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:3 
c++小程序问题求教?
#include <iostream>
#include <string>
 using namespace std;

 struct StudentInfo  //定义学生信息机构体
 {
     string strName;
     int chinese;
     int math;
     int english;
 };
 StudentInfo student[3];
void StudentInput()  //学生信息输入函数
 {
     int i = 0;
     for(i;i<3;i++)
     {
         cout<<"Enter the "<<i+1<<" student information.\n"<<endl;
         cout<<"Enter Name:"<<endl;
         cin>>student[i].strName;
         cout<<"Enter chinese"<<endl;
         cin>>student[i].chinese;
         cout<<"Enter math"<<endl;
         cin>>student[i].math;
         cout<<"Enter english"<<endl;
         cin>>student[i].english;
     }
 }
void StudentOut()//学生信息输出函数
{
    for(int i=0;i<3;i++)
    {
        cout<<"The "<<i+1<<" student information"<<endl;
        cout<<"Name : "<<student[i].strName<<"\n"<<endl;
        cout<<"Chinese : "<<student[i].chinese<<"\n"<<endl;
        cout<<"Math : "<<student[i].math<<"\n"<<endl;
        cout<<"English : "<<student[i].english<<"\n"<<endl;
    }
}
int main()
{
    StudentInput();   
    StudentOut();
    cin.get();
    return 0;
}
我在输入3个学生的信息后,敲回车程序直接退出了,未能显示出输入的学生信息。
搜索更多相关主题的帖子: 信息 english include Enter 
2012-08-07 16:43
chenbofeng20
Rank: 4
来 自:陕西 宝鸡
等 级:业余侠客
威 望:3
帖 子:113
专家分:274
注 册:2009-9-18
收藏
得分:0 
急!!!在线等答案
2012-08-07 16:51
修雅
Rank: 2
等 级:论坛游民
帖 子:8
专家分:30
注 册:2012-6-28
收藏
得分:20 
你的程序没有错 只不过是在执行完最后一步之后 它自动退了出来 以至于你还没来的急看到结果
int main()
{
    StudentInput();
    StudentOut();
    getch();
    return 0;
}
头文件上包含conio
这样他在最后一步执行完了之后,你按下回车他才会退出来


[ 本帖最后由 修雅 于 2012-8-8 10:01 编辑 ]
2012-08-08 09:49
chenbofeng20
Rank: 4
来 自:陕西 宝鸡
等 级:业余侠客
威 望:3
帖 子:113
专家分:274
注 册:2009-9-18
收藏
得分:0 
问题解决,非常感谢!
2012-08-08 15:07
快速回复:c++小程序问题求教?
数据加载中...
 
   



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

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