| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 786 人关注过本帖
标题:帮小弟编写个程序吧
只看楼主 加入收藏
duyushi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-23
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:8 
帮小弟编写个程序吧
题目有10个学生,每个学生的数据包括学号,姓名,3们课的成绩,从键盘输入10个学生的数据,要求打印出3门课的总平均成绩,以及最高分的学生数据:
用C++编写
谢谢了啊
搜索更多相关主题的帖子: 键盘 
2011-06-23 17:48
vandychan
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
等 级:贵宾
威 望:18
帖 子:2296
专家分:6418
注 册:2010-8-20
收藏
得分:4 
不用谢 酬劳怎么算?

到底是“出来混迟早要还”还是“杀人放火金腰带”?
2011-06-23 18:02
duyushi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-23
收藏
得分:0 
帮帮我吧
2011-06-23 18:28
pangding
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:北京
等 级:贵宾
威 望:94
帖 子:6784
专家分:16751
注 册:2008-12-20
收藏
得分:4 
我想没什么人帮你。
网上一搜就能搜到,随便改改应该就能满足你说的要求了吧。
2011-06-23 22:06
trick——3
Rank: 1
等 级:新手上路
帖 子:4
专家分:4
注 册:2011-6-23
收藏
得分:4 
#include <iostream>
using namespace std;
struct student
{
    int n_chenji[3];
    short n_xuehao;
    wchar_t wch_xingmin[5];
};
int main()
{
    student a[10];
    int sum[10];
    for (int i=0;i<=9;i++)
    {
        int v=i+1;
        cout<<"输入学生"<<v<<"姓名"<<endl;
        wcin>>a[i].wch_xingmin;
        cout<<"输入学生"<<v<<"学号"<<endl;
        cin>>a[i].n_xuehao;
        cout<<"输入学生"<<v<<"语文"<<endl;
        cin>>a[i].n_chenji[0];
        cout<<"输入学生"<<v<<"数学"<<endl;
        cin>>a[i].n_chenji[1];
        cout<<"输入学生"<<v<<"英语"<<endl;
        cin>>a[i].n_chenji[2];
    }
    for (int e=0;e<=9;e++)
    {
        sum[e]=a[e].n_chenji[0]+ a[e].n_chenji[1]+a[e].n_chenji[2];
    }
    double ans=(sum[0]+sum[1]+sum[2]+sum[3]+sum[4]+sum[5]+sum[6]+sum[7]+sum[8]+sum[9])*0.1;
    cout<<"3门课的总平均成绩:"<<ans<<endl;
    int temp;
    for (int m=0;m<=9;m++)
    {
        if (sum[m]<sum[m+1])
        {
            temp=m+1;
        }else
        {
            temp=m;
        }
    }        
    cout<<"\n最高分的学生";
    cout<<"姓名";
    wcout<<a[temp].wch_xingmin<<endl;
    cout<<"学号"
        <<a[temp].n_xuehao
        <<"语文"
        <<a[temp].n_chenji[0]
        <<"\n数学"
        <<a[temp].n_chenji[1]
        <<"\n英语"
        <<a[temp].n_chenji[2];
    cin.get();
    cin.get();
    return 0;

   
   
}
//我也是新手
2011-06-23 23:00
海东乖乖
Rank: 2
来 自:甘肃平凉市
等 级:论坛游民
帖 子:4
专家分:11
注 册:2011-6-24
收藏
得分:4 
好好干吧
2011-06-24 10:43
ToBeStronger
Rank: 4
等 级:业余侠客
帖 子:61
专家分:239
注 册:2011-4-8
收藏
得分:4 
#include <iostream>
#include <list>
#include <string>
using namespace std;
struct Student
{
    string itsId;
    string itsName;
    double itsScore1;
    double itsScore2;
    double itsScore3;
    double average;
    double getAverage(){average=(itsScore1+itsScore2+itsScore3)/3;return average;};
    bool operator < (const Student& itemToCompare)const
    {
        return (this->average>itemToCompare.average);
    }   
};
int main()
{
    list<Student> listStudent(10);
    cout<<"请输入10位学生的数据,学号,姓名,三科成绩"<<endl;
    list<Student>::iterator iElement;
    for (iElement=listStudent.begin();iElement!=listStudent.end();iElement++)
    {
        cin>>iElement->itsId>>iElement->itsName>>iElement->itsScore1>>iElement->itsScore2>>iElement->itsScore3;        
    }
    cout<<endl<<endl;
    for (iElement=listStudent.begin();iElement!=listStudent.end();iElement++)
    {
        cout<<"学生: "<<iElement->itsName<<"\t平均成绩: "<<iElement->getAverage();
        cout<<endl;
    }
    cout<<endl<<endl;
    listStudent.sort();
    iElement=listStudent.begin();
    cout<<"最高分学生: "<<iElement->itsId<<"  "<<iElement->itsName
        <<"  "<<iElement->itsScore1<<"  "<<iElement->itsScore2
        <<"  "<<iElement->itsScore3;
    cout<<endl;
    return 0;
}
感觉自己写的不太好,将就看吧,楼主
2011-06-24 10:56
duyushi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-23
收藏
得分:0 
非常感谢
2011-06-24 14:30
jbd0513
Rank: 2
等 级:论坛游民
帖 子:7
专家分:20
注 册:2011-6-17
收藏
得分:0 
顶一下!
2011-06-24 16:44
快速回复:帮小弟编写个程序吧
数据加载中...
 
   



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

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