求一个C用语言写的学生证管理程序,使用Visual C++的集成开发环境 小学期 急 万分感谢

作者&投稿:通巧 (若有异议请与网页底部的电邮联系)
C++问题!写一个学生证管理程序!跪求高手~~

Never_S

建议使用DEV c++,虽然名字是c++但是他也是从c语言中发展过来的。
我一直用的这个,用这个特别简单。就是得在最后添加语句不然程序就会一闪而过,设置一下轻松解决。你可以下载一个试一下,安装文件也不大。Dev-C++目前是NOI、NOIP等比赛的指定工具。

//学生证管理程序
#include"stdio.h"
#include"stdlib.h"
#include"conio.h"
#include"string.h"
#define N 20
typedef struct
{char name[10];
int num;
}stu;
void menu()
{system("cls");
printf("1.学生输入\n");
printf("2.显示\n");
printf("3.退出\n");
printf("请选择:");
}
void input()
{FILE *fp;
stu s;
if((fp=fopen("stu5.dat","ab"))==NULL){printf("can not open file!");exit(0);}
printf("请按格式输入:姓名 学号 (姓名输入ps结束)\n");
while(1)
{scanf("%s",s.name);
if(strcmp(s.name,"ps")==0)break;
scanf("%d",&s.num);
fwrite(&s,sizeof(stu),1,fp);
}
fclose(fp);
}
void output()
{FILE *fp;
stu s[N];
int i=0;
if((fp=fopen("stu5.dat","rb+"))==NULL){printf("can not open file!");exit(0);}
printf("姓名 学号\n");
while(!feof(fp))
{fread(&s[i],sizeof(stu),1,fp);
if(feof(fp))break;
printf("%-15s%d\n",s[i].name,s[i].num);
}
fclose(fp);
getch();
}
void main()
{char ch;
while(1)
{menu();
ch=getche();
if(ch=='3')break;
switch(ch)
{case '1':input();break;
case '2':output();break;
}
}
printf("\n欢迎使用\n");
}

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

#define SIZE 1000
struct student
{
char name[10];
char sex[1];
char coll[15];
char kind[15];
int num;
};

int m,n;

int choice();
int Input(struct student stu[]);
void Print(struct student stu[]);
int add(struct student stu[]);
void PrintOne(struct student stu[]);
void Modify(struct student stu[]);
void Del(struct student stu[]);

void main()
{
struct student stu[SIZE];
int c;
do
{
c=choice();
switch(c)
{
case 0:printf("\nWelcome to this program!");break;
case 1:Input(stu);break;
case 2:add(stu);break;
case 3:Print(stu);break;
case 4:Del(stu);break;
case 5:PrintOne(stu);break;
case 6:Modify(stu);break;
}
}while(c);
}

void DisplayMenu()
{
printf("\n\t\t PLEASE ENTER A NUMBER FROM 0 TO 6!");
printf("\n\n\n\t****************************************************************");
printf("\n\t\t 1 - Input student's informations");
printf("\n\t\t 2 - Add a student's informations");
printf("\n\t\t 3 - Print all student's informations");
printf("\n\t\t 4 - DeL a student's informations");
printf("\n\t\t 5 - Print a student's information");
printf("\n\t\t 6 - Modify a student's information");
printf("\n\t\t 0 - Exit system");
printf("\n\t****************************************************************");
printf("\n\n\n\n\n\n\t\tChoice the number,please:");
}

int choice()
{
int a;
do
{
DisplayMenu();
scanf("%d",&a);
fflush(stdin);
}
while(a<0||a>6);
return a;
}

int Input(struct student stu[])
{
FILE *fp;
int i;

printf("\n\n\t\t\tHow many do you want to input :");
scanf("%d",&m);
fflush(stdin);

for(i=1;i<m+1;i++)
{
printf("\n\n\t\t\t\t =%d=",i);
printf("\n\tInput student's name :");
scanf("%s",&stu[i].name);
fflush(stdin);
printf("\tInput student's sex(M/F) :");
scanf("%s",&stu[i].sex);
fflush(stdin);

printf("\tInput student's college :");
scanf("%s",&stu[i].coll);
fflush(stdin);
printf("\tInput student's kind :");
scanf("%s",&stu[i].kind);
fflush(stdin);
printf("\tInput student's number :");
scanf("%d",&stu[i].num);
fflush(stdin);

printf("\n");}
if((fp=fopen("stu_list","wb"))==NULL)
{
printf("cannot open file\n");
return 1;
}
for(i=0;stu[i].num!=0;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

void Print(struct student stu[])
{
int i;
FILE *fp;
fp=fopen("stu_list","rb");

printf("--------------------------------------------------------------------------------");
for(i=0;i<9;i++)
{
fread(&stu[i],sizeof(struct student),1,fp);

if(stu[i].num!=0)
printf("| %-10s|%-1s|%-15s|%-15s|%-5d|\n",stu[i].name,stu[i].sex,stu[i].coll,stu[i].kind,stu[i].num);

continue;

}
printf("--------------------------------------------------------------------------------");
fclose(fp);
getch();
}

int add(struct student stu[])
{
FILE *fp;

printf("\n\tInput student's name :");
scanf("%s",&stu[0].name);
fflush(stdin);
printf("\tInput student's sex(M/F) :");
scanf("%s",&stu[0].sex);
fflush(stdin);
printf("\tInput student's college :");
scanf("%s",&stu[0].coll);
fflush(stdin);
printf("\tInput student's kind :");
scanf("%s",&stu[0].kind);
fflush(stdin);
printf("\tInput student's number :");
scanf("%d",&stu[0].num);
fflush(stdin);

if((fp=fopen("stu_list","ab"))==NULL)
{
printf("cannot open file\n");
return 1;
}

if(fwrite(&stu[0],sizeof(struct student),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

void PrintOne(struct student stu[])
{
int i,w,x;
FILE *fp;char v[10];
printf("WHAT'S INFORMATION DO YOU KNOW?");
printf("1 - student's name");
printf("2 - student's number");
scanf("%d",&x);
fflush(stdin);

if(x==2)
{ printf("Input this student's number");
scanf("%d",&w);
fflush(stdin);
fp=fopen("stu_list","rb");
for(i=0;i<6;i++)
{
fread(&stu[i],sizeof(struct student),1,fp);
if(stu[i].num==w)
{ printf("%-10s %-3s %-15s %-5s %-5d\n",stu[i].name,stu[i].sex,stu[i].coll,stu[i].kind,stu[i].num);
break;
}
printf("Can't find out this student's information");
}

fclose(fp);
getch();}

else if(x==1)
{printf("Input this student's name");
scanf("%s",v);
fflush(stdin);

fp=fopen("stu_list","rb");
for(i=0;i<6;i++)
{
fread(&stu[i],sizeof(struct student),1,fp);
if(strcmp(stu[i].name,v)==0)
{
printf("%-10s %-3s %-15s %-5s %-5d\n",stu[i].name,stu[i].sex,stu[i].coll,stu[i].kind,stu[i].num);
break;
}

}

fclose(fp);
getch();
printf("Can't find out this student's information");}

}

void Modify(struct student stu[])
{
int i,w,v,m,c;char n; struct student lin[1];
FILE *fp;
printf("input number");
scanf("%d",&w);
fflush(stdin);

fp=fopen("stu_list","rb");
for(i=0;i<9;i++)
{fread(&stu[i],sizeof(struct student),1,fp);}
printf("input your new information");
scanf("%s %s %s %s %d",&lin[0].name,&lin[0].sex,&lin[0].coll,&lin[0].kind,&lin[0].num);
for(i=0;i<9;i++)
{
if(w==stu[i].num)
{strcpy(stu[i].name,lin[0].name);
strcpy(stu[i].sex,lin[0].sex);
strcpy(stu[i].coll,lin[0].coll);
strcpy(stu[i].kind,lin[0].kind);
stu[i].num=lin[0].num;
}
} fclose(fp);
fp=fopen("stu_list","wb");
for(i=0;i<9;i++)
{fwrite(&stu[i],sizeof(struct student),1,fp);}
fclose(fp);

}

void Del(struct student stu[])
{ int i,w,v,m,c;char n;
FILE *fp;;
printf("input number");
scanf("%d",&w);
fflush(stdin);
fp=fopen("stu_list","rb");

for(i=0;i<9;i++)
{fread(&stu[i],sizeof(struct student),1,fp);}
for(i=0;i<9;i++)
{
if(w==stu[i].num)
c=i;
}
fclose(fp);
fp=fopen("stu_list","wb");
for(i=0;i<9;i++)
{if(i!=c)
fwrite(&stu[i],sizeof(struct student),1,fp);
continue;}
fclose(fp);
}

我靠想得美啊你

条件,要求!?


大学生来看C语言学习方法总结
学习语法规则:学习 C 语言的基础知识,需要先了解 C语言的语法规则,包括变量类型、运算符、流程控制语句、函数、指针等。可以通过查阅相关的书籍或者网上的教程进行学o 练习编写代码:C 语言是一种编程语言,只有通过实际编写代码才能真正掌握它的基础知识。可以通过编写简单的程序来加深对语言的理解,例如打印 Hello World...

c语言作业 编写一个输出学生成绩等级的程序
c语言:C语言是一种计算机程序设计语言,它既具有高级语言的特点,又具有汇编语言的特点。它由美国贝尔研究所的D.M.Ritchie于1972年推出,1978年后,C语言已先后被移植到大、中、小及微型机上,它可以作为工作系统设计语言,编写系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序...

用C语言编写:一个学习小组有5个人,每个人有三门课的考试成绩。求全组分...
因为程序是按列录入数据,你键入的前五个数的为1,2,3,2,3,也就是a[1][0]=1;a[2][0]=2; a[3][0]=3; a[4][0]=2; a[5][0]=3;所以按照你写的公式,第一列平均值应该是(1+2+3+2+3)\/5=2.2,但是你键入的输出格式为整形,所以结果为2,完毕,如还有疑...

怎样用geany写一个c语言程序
2、先写代码,再保存时候命名,不过最好先点击保存,然后选择一个工程路径,输入文件名,记住要以 .py结尾,这样它会自动识别为python源程序并语法高亮。3、保存之后我们可以直接敲代码,我们做一个简单的测试代码,先点击编译,再点 执行即可。4、接着会弹出黑色背景框的控制台,同我们熟悉的c语言运行...

设某班有20名同学用c语言写一个程序求某一单科成绩各分数段的分布人数...
include<stdio.h> int main(){ int a[30]={0};int A=0,B=0,C=0,D=0,E=0;for(int i=0;i<20;i++)scanf("%d",&a[i]);\/\/输入20个同学的成绩 for(int i=0;i<20;i++){ switch(a[i]\/10){ case 10:A++;break;case 9:A++;break;case 8:B++;break;case 7:C++;...

用C语言写一个加法运算的代码怎么写?
知识扩展:C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上...

C语音编程题(一个班级有N个学生,每个学生有学号、姓名,学生学习课程...
printf("请输入第%d名学生的英语分数:\\n",i+1);if(stu[j].totalScore>stu[j+1].totalScore){ studenttempStu;printf("名次学号姓名语文数学英语总分平均分\\n");for(i=0;i<n;i++)return0;} 简洁的语言 C语言包含的各种控制语句仅有9种,关键字也只有32个,程序的编写要求不严格且以小写...

怎样用C语言编写一个简单的可以进行加减乘除运算混合运算的计算器?
用C语言编写一个简单的可以进行加减乘除运算混合运算的计算器的方法:1、打开visual C++ 6.0-文件-新建-文件-C++ Source File;2、输入预处理命令和主函数:include<stdio.h> \/*函数头:输入输出头文件*\/ void main()\/*空类型:主函数*\/ 3、定义变量:int a,b,d; \/*定义变量的数据类型为...

C语言关键词学习总结?
C++提供一种提高效率的方法,即在编译时将函数调用处用函数体替换,类似于C语言中的宏展开。这种在函数调用处直接嵌入函数体的函数称为内联函数(inlinefunction),又称内嵌函数或内置函数。 优点:内联函数可以有效避免函数调用的开销,程序执行效率更高。 缺点:如果被声明为内联函数的函数体非常大,则编译器编译后程序...

求一个用c语言链表与文件编写的图书管理系统或者学生信息系统代码加流程...
include <stdio.h>#include <string.h>#include <stdlib.h>const unsigned MAXSTUDS = 150; \/\/ 学生人数const unsigned MAXITEMS = 4; \/\/ 课程数目struct student {unsigned id; \/\/ 学号char name[16];double scores[MAXITEMS + 2]; \/\/ 增加平均成绩和总成绩}stus[MAXSTUDS];int num_stus ...

靖安县18674667805: C语言编写:学生证管理程序(包括姓名、班级、学号、学院等) ,急求啊 -
羽狭派恫: #include<iostream> using namespace std; struct LINK { int num; char a[20]; char b[20]; char c[20]; struct LINK *next; }; void menu() { cout<<"**************************************"<<endl; cout<<"***** 1.创建链表 *****"<<endl; cout<<"***** 2.添加成...

靖安县18674667805: 求一个C用语言写的学生证管理程序,使用Visual C++的集成开发环境 小学期 急 万分感谢 -
羽狭派恫: //学生证管理程序#include"stdio.h"#include"stdlib.h"#include"conio.h"#include"string.h"#define N 20 typedef struct {char name[10]; int num; }stu; void menu() {system("cls"); printf("1.学生输入\n"); printf("2.显示\n"); printf("3.退出\...

靖安县18674667805: 关于C语言的一个小编程,学生成绩管理的程序
羽狭派恫: #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; #include&lt;conio.h&gt; #define N 500 #define NUM 20 #define BAN 30 #define NAME 9 typedef struct { char num[NUM]; char ban[BAN]; char name[NAME]; }STU; STU st[N]; int ...

靖安县18674667805: 跪求C语言大神帮忙弄个学生证管理程序,不要DOS的,要Windows应用程序的. (1)能从键盘输入某位学生的学生证信息 (2)给定学号,显示该学生的学生证信息. (3)给定班号,显示该班所有学生的学生证信息. (4)给定学号,修改该学生的学生证信息. (5)给定学号,删除该学生 -
羽狭派恫: #include <stdio.h>#define SIZE 1000struct student{char name[10];char sex[1];char coll[15];char kind[15];int num;};int choice();int Input();void Print();int add();int m,n;void PrintOne();void Modify();void Del();void main(){struct student stu[SIZE];int c;do{...

靖安县18674667805: 求一个C程的程序,『学生证管理程序』 -
羽狭派恫: fp)!=1) printf(";| %-10s|%-1s|%-15s|%-15s|%-5d|\s name ;tInput student',x.sex;t find out this student',lin[0];#define SIZE 1000 struct student { char name[10];n\%s&quot.name;s number" for(i=0; int m;t\ fclose(fp);," for(i=1; scanf(&quot,&lin[0];t 6 - ...

靖安县18674667805: 如何用C编写一学生证管理系统? -
羽狭派恫: #include"stdio.h" #include"stdlib.h" #include"string.h" #define N 3 typedef struct z1 { char no[11]; char name[15]; int score[N]; float sum; float average; int order; struct z1 *next; }STUDENT; STUDENT *init(); STUDENT *create(); STUDENT *...

靖安县18674667805: 数据结构课程设计(学生证管理程序) -
羽狭派恫: 晚上找时间给你写出来/*【题目描述】 请设计一个学生证的管理程序,该程序应该具有下列功能:(1) 通过键盘输入某位学生的学生证信息.学生证包含的信息请参看自己的学生证;【题目要求】(1) 存储结构采用顺序表或链表;(2) 用本学...

靖安县18674667805: 利用C语言创建个学生信息管理程序!.....急急急!...
羽狭派恫: #include "stdio.h" #include"stdlib.h" #include "conio.h" struct SStudent { unsigned number; char name[10]; char tele[12]; struct SStudent * link; }; void main() {struct SStudent * CreateTable(); void AppendToTable(struct SStudent * stu); void ...

靖安县18674667805: 用c语言编写控制台下简单的学籍管理程序
羽狭派恫: 太长,剩下的联系我,发给你!nbsp;/*11.3.2nbsp;源程序*/nbsp;/***********xuesheng.c***********/nbsp;/******头文件(.h)***********/nbsp;#includenbsp;“stdio.h“nbsp;/*I/O函数*/nbsp;#includenbsp;“stdlib.h“nbsp;/*其它说明*/nbsp;#...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网