当前位置:编程问答 > C/C++ >

C程序设计:一个教务管理系统的设计,包括学生姓名,学号,成绩,求高手设计方法

答案:http://www.pudn.com/downloads36/sourcecode/app/detail115926.html专门针对你说的写了一个简单点的程序你看看可以用不???// 学生成绩管理系统.cpp : Defines the entry point for the console application.///*求C++课程设计答案,望高手相助 悬赏分:50 - 离问题结束还有 17 天 5 小时 设计一个学生类,包括数据成员姓名、分数、等级(字符型数组),设计友元函数,用来根据成绩分数确定对应的等级:90~100:优; 80~89:良; 70~79:及格; 60以下:不及格; disp()成员函数用来显示学生的数据。主函数中定义学生类对象数组,初始化姓名和分数;输出结果;显示每个学生的姓名、分数、等
其他:最近都是课程实践的问题 哎~~~
 看看能不能用


#include <stdio.h>
#include <string.h>

const int MAX_NUM = 5;

const int MAX_NAME_LEN = 127;
const int MAX_SUBJECT = 3;
const double SUBJECTS = 3.0;

typedef struct _Student
{
 char szName[MAX_NAME_LEN + 1];
 int nArryScore[MAX_SUBJECT];
 int nSum;
 double dAverage;
}Student;

void Sort(Student students[], int n)
{
 Student stTmp;
 int nTmp = 0;
 int nPos = 0;
 int nIndex = 0;
 for (nPos = 0; nPos < n - 1; nPos++)
 {
  nTmp = nPos;
  memset(&stTmp, 0, sizeof(Student));
  for (nIndex = nPos + 1; nIndex < n; nIndex++)
  {
   if (students[nIndex].nSum > students[nTmp].nSum)
   {
    nTmp = nIndex;
   }
  }

  memcpy(&stTmp, &students[nTmp], sizeof(Student));
  memcpy(&students[nTmp], &students[nPos], sizeof(Student));
  memcpy(&students[nPos], &stTmp, sizeof(Student));
 }
}

int main (void)
{
 printf("请输入五个同学三门课的成绩:\n");

 Student students[MAX_NUM];
 memset(students, 0, sizeof(students));

 Student* pStudent = NULL;

 int nCnt = 0;
 int nPos = 0;
 while (MAX_NUM > nCnt)
 {
  printf("第%d个同学的记录:", nCnt + 1);

  pStudent = &students[nCnt];
  scanf("%s %d %d %d", pStudent->szName,
   &pStudent->nArryScore[0], 
   &pStudent->nArryScore[1], 
   &pStudent->nArryScore[2]);
  for (nPos = 0; nPos < MAX_SUBJECT; nPos++)
  {
   pStudent->nSum += pStudent->nArryScore[nPos];
  }

  pStudent->dAverage = pStudent->nSum / SUBJECTS;
  nCnt++;

  getchar();
 }

 Sort(students, MAX_NUM);

 printf("------------------------------------------------\n");
 printf("输出排序后五个同学的三门成绩:\n");
 printf("------------------------------------------------\n");
 printf("排序  姓名   课1   课2   课3    总分   平均分\n");
 for (nPos = 0; nPos < MAX_NUM; nPos++)
 {
  pStudent = &students[nPos];
  printf("第%d名: %s  %d %d %d %d %.2f\n", nPos + 1,
   pStudent->szName, 
   pStudent->nArryScore[0], 
   pStudent->nArryScore[1], 
   pStudent->nArryScore[2],
   pStudent->nSum,
   pStudent->dAverage);
 }


 return 0;
} 

上一个:C语言递归子函数
下一个:C语言编写子函数

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,