| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2066 人关注过本帖
标题:C语言大作业,下周就要交,求教
只看楼主 加入收藏
凌夜
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2017-12-12
结帖率:0
收藏
 问题点数:0 回复次数:5 
C语言大作业,下周就要交,求教
学生成绩数据处理系统
定义结构包括:学号、姓名、班级和大学数学、计算机导论、C语言三科成绩
实现功能:
学生成绩信息的录入
修改指定学生成绩信息
查询符合条件的学生成绩信息
按C语言成绩进行降序排
删除学生记录
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 10
struct student
 {
     char  num[5];
     char name[20];
     int  score;
 };
struct student stu[N] = { { "1","张三",90 },{ "2","李四",87 },{ "3","王五",76 },{ "4","赵六",67 },{ "5","刘七",56 } };

int count = 5;

void insert(int i)   //输入学生具体信息的函数
{
     printf("第%d个学生的姓名:", i + 1);

     scanf("%s", stu[i].name);

     printf("\n");

     printf("第%d个学生的分数:", i + 1);

     scanf("%d", &stu[i].score);

     printf("\n");

     count++;
     sprintf(stu[i].num,"%d",count);
 }

void input()     //输入数据的函数
{
     system("color 3e");
     void menu();
     void insert(int i);
     int i, j, k, l, r;
     printf("您想输入几个学生的信息? (1-%d) [ ]\b\b", N - 5);
     scanf("%d", &j);
     r = 5 + j;
     for (i = 5; i<r; i++)
     {
         printf("\n输入第%d个学生的信息。\n", i + 1);
         insert(i);
     }
     do
     {
         printf("返回菜单请按1! [ ]\b\b");
         scanf("%d", &k);
         if (k == 1)
         {
             system("cls");
             menu();
         }
         else
             l = 0;
     } while (l == 0);
 }





void search()        //查询成绩的函数
{
     void menu();
     void printf_one(int k);
     struct student s;
     int i, k, w0, w1, w2;
     do
     {
         printf("请选择查找的类别:  1.姓名   2.学号   [ ]\b\b");
         scanf("%d", &w1);
         if (w1<1 || w1>2)
         {
             printf("输入错误!请重新输入!\n");
             w2 = 1;
         }
         else
             w2 = 0;
     } while (w2 == 1);
     if (w1 == 1)  //按姓名查找
    {
         do
         {
             k = -1;
             do
             {
                 printf("\n请输入您想查找的学生的姓名!\nName:");
                 scanf("%s", s.name);
                 for (i = 0; i<5; i++)
                     if (strcmp(s.name, stu[i].name) == 0)
                     {
                         k = i;
                         s = stu[i];
                     }
                 if (k == -1)  //没有找到
                {
                     int o;
                     printf("\n\n没有这个学生的信息!\n");
                     printf("What do you want to do?\n\t1.继续   2.返回菜单  [ ]\b\b");
                     scanf("%d", &o);
                     if (o == 1)
                     {
                         system("cls");
                         search();   //继续查找
                    }
                     else
                     {
                         system("cls");
                         menu();   //返回菜单
                    }
                 }
             } while (k == -1);
             system("cls");
             printf_one(k);     //查找到以后输出这个学生的信息
            printf("\nWhat do you want to do?\n\t1.继续   2.返回菜单   [ ]\b\b");
             scanf("%d", &w0);
         } while (w0 == 1);
         system("cls");
         menu();   //不在查找时返回菜单
    }
     else    //按学号查找
    {
         do
         {
             k = -1;
             do
             {
                 printf("\n请输入您想查找的学生的学号!\nNum:");
                 scanf("%s", s.num);
                 for (i = 0; i<5; i++)
                     if (strcmp(s.num, stu[i].num) == 0)  //找到了
                    {
                         k = i;
                         s = stu[i];
                     }
                 if (k == -1)    //没有找到
                {
                     int o;
                     printf("\n\n没有这个学生的信息!\n");
                     printf("What do you want to do?\n\t1.继续   2.返回菜单  [ ]\b\b");
                     scanf("%d", &o);
                     if (o == 1)
                     {
                         system("cls");
                         search();  // 继续查找
                    }
                     else
                     {
                         system("cls");
                         menu();    //返回菜单
                    }
                 }
             } while (k == -1);
             system("cls");
             printf_one(k);   //找到后输出这个学生的信息
            printf("\nWhat do you want to do?\n\t1.继续  2.返回菜单   [ ]\b\b");
             scanf("%d", &w0);
         } while (w0 == 1);
         system("cls");
         menu();     //不在查找时返回菜单
    }

 }



潇湘剑雨 2017/12/23 21:00:29
void xiugai()     //修改学生信息的函数
{
     void menu();
     void printf_one(int k);
     void xiugai_2();
     struct student s;
     int i,n,k,w0=1,w1,w2=0,o;
     do
     {
         k=-1;
         do
         {
             printf("\n请输入您想要修改的学生的姓名!Name:");
             scanf("%s",s.name);
             for(i=0;i<5;i++)
             if(strcmp(s.name,stu[i].name) == 0)  //与其中一个学生匹配
            {
                 k = i;
                 s = stu[i];
             }
             if(k == -1)   // 没有找到输入的学生
            {               
                 printf("\n\n没有这个学生的信息!\n");
                 printf("What do you want to do?\n\t1.继续  2.返回菜单  [ ]\b\b");
                 scanf("%d",&o);
                 if(o == 1)
                 {
                     system("cls");
                     //xiugai();    //继续修改
                }
                 else
                 {
                     system("cls");
                     menu();    //返回菜单
                }
             }

         }while(k == -1);
         system("cls");
         printf("修改这个学生的分数:");

         scanf("%d", &stu[k].score);
         printf("\n");
         printf_one(k);   //输出这个学生的信息
        printf("\nWhat do you want to do?\n\t1.继续  2.返回菜单  [ ]\b\b");
         scanf("%d", &o);
         if (o != 1)
         {
             system("cls");
             menu();    //返回菜单
        }
     }while(1);
 }



void printf_all()       //输出所有学生成绩的函数
{
     void menu();
     system("color 4e");
     int i, j, k;
     for (i = 0; i<N; i++)
     {
         printf("学号:%s    姓名:%s    分数:%d\n", stu[i].num, stu[i].name, stu[i].score);
     }
     do
     {
         printf("返回菜单请按1  [ ]\b\b");
         scanf("%d", &j);
         if (j == 1)
         {
             system("cls");
             menu();
         }
         else
         {
             k = 0;
         }
     } while (k == 0);
 }
请赐教
搜索更多相关主题的帖子: 学生 printf scanf system do 
2017-12-23 21:36
虫眼
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:10
帖 子:314
专家分:1121
注 册:2017-11-29
收藏
得分:0 
居然没有主函数,服了you!
2017-12-23 22:03
凌夜
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2017-12-12
收藏
得分:0 
回复 2楼 虫眼
呃呃,作为一个C语言渣渣,实在是有心无力谢谢大神指点,不过还是,,,
2017-12-26 21:14
凌夜
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2017-12-12
收藏
得分:0 
还有编程功力不够,缺乏题目的相关功能,望大神指点
2017-12-26 21:15
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
这类写作有不少
搜索“学生成绩”怕你没时间看
2017-12-26 21:57
凌夜
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2017-12-12
收藏
得分:0 
回复 5楼 吹水佬
确实没时间看,而且下周必须完成
2017-12-27 13:37
快速回复:C语言大作业,下周就要交,求教
数据加载中...
 
   



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

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