广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2604 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
jianfengtw
数位造型
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x3
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[C/C++] [请教]成绩表分数的组距诸位大大你们会怎么写
功能如下
Exercise 4 : Please design a C++ program which allows user to enter the total students in class, student’s name, id and 3 scores, please do the followings:

1.Show Exercise No., Class, Name, and ID
2.Enter the total students, student’s name, id and 3 scores
3.Show all the student’s records
4.Show the distribution of each course
5.Ues new and delete operators to allocate memory dynamincally
Hints : struct Student{ // 定义一个结构资料型态Student
string id;
string name;
int score;
float average;
} ;
Student *rptr=new Student;
rptr.name=“Eric”;

Exercise 4
Class : x子xA Name : xxx ID : D9833045
How many students in class : 2
Name of student 1 : Eric
ID of student 1 : D9833007
Score 1 of student 1 : 89
Score 2 of student 1 : 56
Score 3 of student 1 : 74
Name of student 2 : Mary
ID of student 2 : D9833004
Score 1 of student 2 : 80
Score 2 of student 2 : 66
Score 3 of student 2 : 44
…………
Press any key to print class record

Name ID Score1 Score2 Score3 Average
Eric D9833007 89 56 74 73
Mary D9833004 80 66 44 63
…………
最主要显示这个
Course 1 :
100~90 : 0
89~80 : 0
79~70 : 1
Name: Eric ID:D9833007 Score:73
69~60 : 1
Name: Mary ID:D9833004 Score:63
59~0 : 0 ………….

事实上我已经写好了
但是写的很长觉的自已写的很猪头
不知道有没有比较简短的写法

不知道哪一位大大可以帮我解
Hints : struct Student{ // 定义一个结构资料型态Student
string id;
string name;
int score;
float average;
} ;
Student *rptr=new Student; <--还有这二段我看不太了解
rptr.name=“Eric”; <--不知道哪一位大大可以帮我
说明一下
为什么可这样做

这是我写的程式

//

#include "stdafx.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int i,j,n;
int max=0,min=0;
int total={0};
cout <<"Exercise 4"<<endl;
cout <<"Class : X子XA Name : XXX ID : DXXXXXXXXX " << endl;
cout <<"How many students in class:";
cin >> n;

struct person {char name;// 定义一个结构资料型态Student
..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



[ 此文章被jianfengtw在2005-04-23 16:57重新编辑 ]



献花 x0 回到顶端 [楼 主] From:台湾台湾索尼 | Posted:2005-04-23 01:41 |
kk889180
个人头像
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x61
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

下面是引用jianfengtw于2005-04-23 01:41发表的 [请教]成绩表分数的组距:

Student *rptr=new Student[100]; <--还有这二段我看不太了解
rptr[2].name=“Eric”;           <--不知道哪一位先生可以帮我说明一下
.......

宣告一阵列rptr为学生结构


[ 此文章被kk889180在2005-04-23 22:43重新编辑 ]


献花 x0 回到顶端 [1 楼] From:台湾亚太线上 | Posted:2005-04-23 07:19 |
jianfengtw
数位造型
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x3
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

谢谢k大的解答
了解了~~
但我想知道
比较组距的分法
个位大大会怎么写


献花 x0 回到顶端 [2 楼] From:台湾台湾索尼 | Posted:2005-04-23 16:59 |
kk889180
个人头像
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x61
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

哈哈你被我骗了
我前面的是错的喔 表情
之前以为是要把三种分数分为cause 1,2,3讨论(该打该打 表情 )
叫我popo就好了,因为我想努力po文章,后面加个大很奇怪,因为我算新手 表情

这应该算平凡的打法吧 表情
只是把你程式一个一个打的地方换成回圈
复制程式
#include<stdio.h>
#include<conio.h>
#define swap(float x,float y) {int t;t=x;x=y;y=t;}
struct person
{
 char name[ 10 ];
 char id[ 10 ];
 int score[ 3 ];
 float average;
};

void main()
{
 FILE *fin,*fout;
 int i,l,j,num=5,n=0;
 person *student[ 5 ];
 for(l=0;l<num;l++)
 {
  scanf("%s %s",student[ l ].name,student[ l ].id);
  for(i=0;i<3;i++) 
  {
   scanf("%d",student[ l ].score[ i ]);
   student[ l ].average += student[ l ].score[ i ];
  }
  student[ l ].average /= 3;
 }
 for(i=0;i<n;i++) 
 { 
  for(j=i+1;j<n;j++) 
  { 
   if(student[ i ].average<student[ l ].average);
   {
    swap(student[ l ].average,student[ l ].average);
   }  
  } 
 }
 l=0;
 i=89;
 while(i>=0)
 {
  if(student[ l ].average>i) 
  {
   n++;
   l++;
  }
  else
  {
   if(i>58) 
   {
    if(i==89)printf("%d~%d = %d",i+11,i+1,n);
    else printf("%d~%d = %d",i+10,i+1,n);
   }   
   else
   {
    printf("Name : %s ID : %s",student[ l ].name,student[ l ].id);
    printf("%d~%d = %d",i+10,i+1,n);
   }
   i-=10;
   n=0;
  }
 }
}


[ 此文章被kk889180在2005-04-23 23:29重新编辑 ]


献花 x0 回到顶端 [3 楼] From:台湾亚太线上 | Posted:2005-04-23 22:43 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.014685 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言