c语言编程

阅读 / 问答 / 标签

用C语言编程学生信息管理系统!

/*【学生管理系统】*///modify#include<stdio.h>#include<string.h>#include<conio.h>#include<stdlib.h>#include<time.h>#define N 100typedef struct student{ int num; //学号,姓名,年龄,性别,出生年月,地址,电话, char name[18]; char sex; int age; int y,m; int tel; char add[30]; char mail[20]; int res; int stu;} SDate;int PassWord();void Menu();int Input_Choice(); //函数声明void Info_Paixu(SDate *student,int n);void Info_print(SDate *stu,int n);int Input_file(SDate *stu1);int Info_Input(SDate *stu,int count);void Info_Seach(SDate *stu,int n);void Info_Change(SDate *stu,int n,int Num);void Exit();void Print_file(SDate *stu,int n);int Info_Del(SDate *stu, int n, int del);void Info_Change(SDate *stu, int res, int choice);int Info_Add(SDate *stu, int count);int main(){ SDate stu[N]; int ret=0,res=0,choice=0; char ch;loop: ret=PassWord(); //登录函数 默认密码为admin if(!ret) { system("cls"); printf(" 密码错误或验证码错误! "); //默认密码:admin system("pause"); system("cls"); goto loop; } system("cls");e: Menu(); //菜单显示函数 printf("你的选择是? "); scanf("%d",&ret); switch(ret) { case 1: choice=Input_Choice(); //InputChoice()数据输入方式选择函数 if(choice==1) res=Info_Input(stu,res); //键盘输入函数 else if(choice==2) res=Input_file(stu); //文件读取函数 else { system("cls"); goto e; } break; case 2: if(res==0) { system("cls"); printf("没有数据输入,请重新选择! "); goto e; } else Info_print(stu,res); break; case 3: if(res==0||res==1) { system("cls"); printf("没有需要排序数据,请重新选择! "); goto e; } else Info_Paixu(stu,res); break; case 4: Info_Seach(stu,res); break; case 5: res=Info_Add(stu,res); break; case 6: Info_print(stu,res); printf("输入学号进行删除:"); scanf("%d",&choice); res=Info_Del(stu, res, choice); break; case 7: printf("请输入需要修改的学号:"); scanf("%d",&choice); Info_Change(stu,res,choice); break; case 8: Print_file(stu, res); break; case 9: Exit(); break; default : printf("您的选泽有误! "); } getchar(); printf("返回主菜单重新选择y/n?"); scanf("%c",&ch); if(ch=="Y"||ch=="y") { system("cls"); goto e; } return 0;}int yanzheng() //验证码模块{ int a,b,c,d; srand((unsigned)time(NULL)); a=rand()%100; b=rand()%100; c=a+b; printf(" ************************** "); printf(" 验证码: %d+%d=? ",a,b); printf(" 答案为:"); scanf("%d",&d); if(c==d) return 1; else return 0;}int PassWord() //登录模块{ int i=0; char passWord[18]; char p[]="admin"; //默认密码设置 char ch; printf(" 欢迎使用学生信息管理系统 "); printf(" "); printf(" 用户名:Admin "); printf(" "); printf(" 密码:"); while((ch=getch())!=13) { putchar("*"); passWord[i]=ch; i++; } passWord[i]=""; if(strcmp(p,passWord)==0) yanzheng(); else return 0;}void Menu() //菜单模块{ printf(" 欢迎使用学生信息管理系统 "); printf(" ******************************************* "); printf("** 1、学生信息录入 ** "); printf("** 2、学生信息浏览 ** "); printf("** 3、学生信息排序 ** "); printf("** 4、学生信息查找 ** "); printf("** 5、学生信息添加 ** "); printf("** 6、学生信息删除 ** "); printf("** 7、学生信息修改 ** "); printf("** 8、学生信息保存 ** "); printf("** 9、退出 ** "); printf("******************************************* ");}int Input_Choice() //数据输入方式选择{ int i; system("cls"); printf(" 欢迎使用学生信息管理系统 "); printf(" 1、键盘录入 "); printf(" 2、文件读取 "); printf(" 0、返回 "); printf(" 你的选择是?"); scanf("%d",&i); return i;}int Info_Input(SDate *stu,int count) //信息从键盘输入模块{ SDate *p; p=stu; system("cls"); printf("请输入第%d个学生学号(输入0结束): ",count+1); scanf("%d",&p->num); while(p->num!=0) { printf("请输入该学生姓名: "); scanf("%s",p->name); printf("请输入该学生年龄: "); scanf("%d",&p->age); getchar(); printf("请输入该学生性别: "); scanf("%c",&p->sex); printf("请输入该学生出生年月: "); scanf("%d%d",&p->y,&p->m); printf("请输入该学生住址: "); scanf("%s",p->add); printf("请输入该学生联系电话: "); scanf("%d",&p->tel); printf("请输入该学生E-Mail: "); scanf("%s",p->mail); count++; p++; system("cls"); printf("请输入第%d个学生学号(输入0结束): ",count); scanf("%d",&p->num); } return count;}int Input_file(SDate *stu1) //信息从文件输入模块{ int rin=0; SDate *p; FILE *fp; p=stu1; if((fp=fopen("StuInfo.txt","r"))==NULL) printf("该文件不存在! "); while(!feof(fp)) { fscanf(fp,"%d %s %c %d %d %d %d %s %s ",&p->num,p->name,&p->sex,&p->age,&p->y,&p->m,&p->tel,p->add,p->mail); p++; rin++; } fclose(fp); printf("文件读取成功! "); return rin;}void Info_print(SDate *stu,int n) //信息输出至屏幕模块{ SDate *p; if(n==0) //学号,姓名,年龄,性别,出生年月,地址,电话, printf("没有录入信息! "); else { printf(" 以下是%d个同学的信息 ",n); printf("学号 姓名 性别 年龄 出生年月 电话 地址 E-Mail "); for(p=stu; p<stu+n; p++) printf("%d %s %c %d %d-%d %d %s %s ",p->num,p->name,p->sex,p->age,p->y,p->m,p->tel,p->add,p->mail); }}void Print_file(SDate *stu,int n) //信息保存至文件模块{ FILE *fp; SDate *p; p=stu; if((fp=fopen("StuInfo.txt","a"))==NULL) printf("文件读取失败! "); else { for(; p<stu+n; p++) fprintf(fp,"%d %s %c %d %d %d %d %s %s ",p->num,p->name,p->sex,p->age,p->y,p->m,p->tel,p->add,p->mail); fclose(fp); printf(" 保存成功! "); }}void Info_Paixu(SDate *stu,int n) //学号排序模块{ int i,j; SDate p; for(i=0; i<n-1; i++) { for(j=0; j<n-1-i; j++) { if((stu[j].num)>(stu[j+1].num)) { p=stu[j]; stu[j]=stu[j+1]; stu[j+1]=p; } } } printf("排序完成! ");}void Exit() //退出模块{ printf("谢谢使用! "); exit(1);}void Info_Seach(SDate *stu,int n) //查询模块,目前仅支持学号或姓名的精准查询{ int num,choice; char name[10]; int flag=-1,i; system("cls"); printf("请输入查询方式: 1、学号查询 2、名字查询 "); printf("您的选择是?"); scanf("%d",&choice); if(choice==1) {lab1: printf("请输入需要查找的学号: "); scanf("%d",&num); for(i=0; i<n; i++) { if(num==stu[i].num) { flag=i; printf("%d %s %c %d %d-%d %d %s %s ",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].y,stu[i].m,stu[i].tel,stu[i].add,stu[i].mail); } } if(flag==-1) { printf("未找到!请重新选择 "); printf("1、返回继续查询 2、退出查询,返回主菜单 3、退出程序你的选择是?"); scanf("%d",&choice); if(choice==1) { system("cls"); goto lab1; } if(choice==2) goto end; else Exit(); } } else if(choice==2) {lab2: printf("请输入需要查找的姓名: "); scanf("%s",name); for(i=0; i<n; i++) if(strcmp(name,stu[i].name)==0) { flag=i; printf("%d %s %c %d %d-%d %d %s %s ",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].y,stu[i].m,stu[i].tel,stu[i].add,stu[i].mail); } if(flag==-1) { printf("您的输入有误!请重新选择 "); printf(" 1、返回继续查询 2、退出查询,返回主菜单 3、退出程序 你的选择是?"); scanf("%d",&choice); if(choice==1) { system("cls"); goto lab2; } if(choice==2) goto end; else Exit(); } }end: ;}void Info_Change(SDate *stu,int n,int Num) //信息修改模块{ int i; for(i=0; i<n; i++) if(stu[i].num==Num) { printf("请输入该学生姓名: "); scanf("%s",stu[i].name); printf("请输入该学生年龄: "); scanf("%d",&stu[i].age); getchar(); printf("请输入该学生性别: "); scanf("%c",&stu[i].sex); printf("请输入该学生出生年月: "); scanf("%d%d",&stu[i].y,&stu[i].m); printf("请输入该学生住址: "); scanf("%s",stu[i].add); printf("请输入该学生联系电话: "); scanf("%d",&stu[i].tel); printf("请输入该学生E-Mail: "); scanf("%s",stu[i].mail); printf("学号为%d的同学信息修改完成! ",Num); }}int Info_Del(SDate *stu, int n, int del) //信息删除模块{ int i,j; for(i=0; i<n; i++) if(stu[i].num==del) for(j=i; j<n-1; j++) stu[j]=stu[j+1]; n--; printf("删除成功! "); return n;}int Info_Add(SDate *stu,int count) //信息添加模块{ SDate *p; system("cls"); printf("当前共有%d个数据 ",count+1); p=stu+(count); printf("请输入第%d个学生学号(输入0结束): ",count+1); scanf("%d",&p->num); while(p->num!=0) { printf("请输入该学生姓名: "); scanf("%s",p->name); printf("请输入该学生年龄: "); scanf("%d",&p->age); getchar(); printf("请输入该学生性别: "); scanf("%c",&p->sex); printf("请输入该学生出生年月: "); scanf("%d%d",&p->y,&p->m); printf("请输入该学生住址: "); scanf("%s",p->add); printf("请输入该学生联系电话: "); scanf("%d",&p->tel); printf("请输入该学生E-Mail: "); scanf("%s",p->mail); count++; p++; system("cls"); printf("请输入第%d个学生学号(输入0结束): ",count+1); scanf("%d",&p->num); } return count;}

学生信息管理系统C语言编程

童鞋你这个要别人怎么回答你呢?就把一些要求写在上面,多自己想想吧.这些不难,你现在不想以后也要想,呵呵

C语言编程_幸运52猜数游戏__

我的心里都是你,⑧② ⑥ ③ ⑧ ⑤ · 匚 ō г n 一颦一笑,或者百般模样。

C语言编程题 从键盘上输入一年份,判断年份是否为闰年

你就给他两个if,然后进行嵌套,然后分别整除那两个数字就可以。

c语言编程:输入一个年份,判断其是否为闰年,并输出判断结果。

#include "stdio.h"int main(){ int year; printf("please input a year: "); scanf("%d",&year); if( ( year%400 == 0 ) || ( year%100 != 0) && ( year%4 == 0) ) printf("yes,it is a leap year! ");else printf("NO.It"s not a leap year");return 0;}}

C语言编程编译没问题 但进入不到主函数

没有良好的编程书写习惯。看着难受啊。

数据结构与算法作业:用C语言编程随机生成一个迷宫,然后找出从入口到出口的路线图。急!

#include <stdio.h>#include <stdlib.h>#include <time.h>#include <memory.h>/* define the size of maze */#define MAX_COL 6#define MAX_ROW 6#define TRUE 1#define FALSE 0#define IS_USABLE(a, b) (a >= 0 && a < MAX_ROW) && (b >= 0 && b < MAX_COL) && maze[a][b] && (!my_maze[a][b])static int maze[MAX_ROW][MAX_COL];static int target_maze[MAX_ROW][MAX_COL];static void init_maze();static int move_to(int i, int j, int (*maze)[MAX_COL], int count);static void print_maze(int (*maze)[MAX_COL]);static void init_maze(){ int i, j; srand((unsigned) time(NULL)); for (i = 0; i < MAX_ROW; i++) for(j = 0; j < MAX_COL; j++) { maze[i][j] = (int) (rand() % 2); } maze[1][0] = 1; /* start point */ maze[MAX_ROW - 1][MAX_COL - 2] = 1; /* end point */}static int move_to(int _i,int _j, int (*in_maze)[MAX_COL], int count) { int my_maze[MAX_ROW][MAX_COL], i, j; if (!in_maze) { for (i = 0; i < MAX_ROW; i++) for(j = 0; j < MAX_COL; j++) { my_maze[i][j] = 0; } } else { for (i = 0; i < MAX_ROW; i++) for(j = 0; j < MAX_COL; j++) { my_maze[i][j] = in_maze[i][j]; } } my_maze[_i][_j] = count; /* reach the end point */ if (_i == MAX_ROW - 1 && _j == MAX_COL - 2) { for (i = 0; i < MAX_ROW; i++) for(j = 0; j < MAX_COL; j++) { target_maze[i][j] = my_maze[i][j]; } return TRUE; } if (IS_USABLE(_i - 1, _j)) { if (move_to(_i - 1, _j, my_maze, count + 1)) return TRUE; } if (IS_USABLE(_i + 1, _j)) { if (move_to(_i + 1, _j, my_maze, count + 1)) return TRUE; } if (IS_USABLE(_i, _j - 1)) { if (move_to(_i, _j - 1, my_maze, count + 1)) return TRUE; } if (IS_USABLE(_i, _j + 1)) { if (move_to(_i, _j + 1, my_maze, count + 1)) return TRUE; } return FALSE;}static void print_maze(int (*maze)[MAX_COL]) { int i, j; for (i = 0; i < MAX_ROW; i++) { for(j = 0; j < MAX_COL; j++) { if (maze[i][j] != 0) printf("%d ", maze[i][j]); else printf(" "); } printf(" "); }}int main(){ while(1) { init_maze(); printf("Out put the maze : "); print_maze(maze); if (move_to(1, 0, NULL, 1)) { printf("Out put the path : "); print_maze(target_maze); break; } else { printf("No way! "); } }}VC60下正常运行

有哪位大仙能够帮帮我这道C语言编程题!

/*学生通讯录管理系统:1.学生信息包括:学号、姓名、性别、生日、年龄和平均分;2.用链表实现;3.可以浏览学生信息,插入学生信息(在任意位置插入学生信息),新增学生信息(在链表尾部新增学生信息),删除学生信息,查找学生信息和修改学生信息.*/#include<stdio.h> #include<stdlib.h> #include<string.h> #include<malloc.h>typedef struct student_info { char stu_name[15]; long stu_num; char stu_sex[10]; char Birthday[30]; char age[30]; char Gpa[15]; struct student_info *next; }Student; Student *head; /*为全局变量*/Student *load() /*载入函数,从文件中读数据建立链表*/ { FILE *fp; Student *head_1,*p,*q; head_1=NULL; fp=fopen("student","rb"); if(fp==NULL) { fp=fopen("student","wb"); fclose(fp); return head_1; } p=(Student*)malloc(sizeof(Student)); if(fread(p,sizeof(Student),1,fp)!=1) return head_1; head_1=p; while(!feof(fp)) { q=p; p=(Student*)malloc(sizeof(Student)); fread(p,sizeof(Student),1,fp); q->next=p; } q->next=NULL; free(p); fclose(fp); return head_1; } int save() /*将修改后的链表中的信息存进文件中*/{ FILE *fp; fp=fopen("student","wb"); while(head!=NULL) { fwrite(head,sizeof(Student),1,fp); head=head->next; } fclose(fp); return 0; } int Add_student() /*添加学生信息函数 */{ Student *p,*q; Student *stud1; char flag="y"; stud1=(Student*)malloc(sizeof(Student)); while(flag=="y"||flag=="Y") { q=p=head; printf("请输入要添加的学生的姓名: "); scanf("%s",stud1->stu_name); printf("请输入要添加的学生的学号(最多8位数): "); scanf("%ld",&stud1->stu_num); printf("请输入要添加的学生的性别: "); scanf("%s",&stud1->stu_sex); printf("请输入要添加的学生的生日: "); scanf("%s",&stud1->Birthday); printf("请输入要添加的学生的年龄: "); scanf("%s",&stud1->age); printf("请输入要添加的学生的平均分: "); scanf("%s",&stud1->Gpa); stud1->next=NULL; fflush(stdin); if(head==NULL)head=stud1; else { while(p->stu_num<stud1->stu_num&&p->next!=NULL) {q=p;p=p->next;} if(p->stu_num>stud1->stu_num) if(p==head){stud1->next=head;head=stud1;} else {q->next=stud1;stud1->next=p;} else p->next=stud1; } stud1=(Student*)malloc(sizeof(Student)); printf("添加结束,是否继续添加,"y"或"Y"继续,否者退出! "); flag=getchar(); fflush(stdin); } free(stud1); system("cls"); return 0; } int del_stu() /*按学号删除学生信息函数*/ { Student *p,*q; long stu_num; char flag="y"; int tage=0; while(flag=="y"||flag=="Y") { p=head; printf(" input the delete student number! "); scanf("%d",&stu_num); if(head==NULL){printf("不存在学生信息! ");return 0;} while(p!=NULL) { if(p->stu_num==stu_num) { tage=1; if(p==head)head=head->next; else q->next=p->next; free(p);break; } q=p;p=p->next; } if(tage==0) printf("要删除的学生信息不存在! "); tage=0; printf("删除结束,是否继续删除操作:y或Y继续,否者结束! "); fflush(stdin); scanf("%c",&flag); } system("cls"); return 0; } int find_student() /*按学号查找学生信息*/{ Student *p; char flag="y"; long stu_num; int tage=0; /*1作为找到学生的标志,0为没有找到*/ while(flag=="y"||flag=="Y") { printf("input the finding student number! "); scanf("%d",&stu_num); p=head; if(head==NULL){printf("不存在学生信息! ");return 0;} else while(p!=NULL) if(p->stu_num==stu_num) { tage=1; printf("你要查找的学生信息如下: "); printf("%s %ld %s %s %s %s ",p->stu_name,p->stu_num,p->stu_sex,p->Birthday,p->age,p->Gpa); break; } else p=p->next; if(tage==0)printf("无该学生信息! "); tage=0; printf("查找结束,是否继续查找操作:y或Y继续,否者退出! "); fflush(stdin); scanf("%c",&flag); } return 0; } int ame_student() /*修改学生信息*/ { Student *p; long stu_num; int tage=0; int chiose; char flag="y"; printf("input the change student number! "); scanf("%ld",&stu_num); p=head; while(flag=="y"||flag=="Y") { if(head==NULL){printf("无学生信息存在! ");return 0;} while(p!=NULL) { if(p->stu_num==stu_num) { tage=1; printf("请选要修改的编号! "); printf("1:<修改姓名> "); printf("2:<修改学号> "); printf("3:<修改性别> "); printf("4:<修改生日> "); printf("5:<修改年龄> "); printf("6:<修改平均分> "); printf("请输入1-6!else非法! "); scanf("%d",&chiose); switch(chiose) { case 1: { char stu_name[15]; printf("请输入修改的名字! "); scanf("%s",stu_name); strcpy(p->stu_name,stu_name); break; } case 2: { long stu_num; printf("请输入修改的学号! "); scanf("%ld",&stu_num); p->stu_num=stu_num; break; } case 3: { char stu_sex[10]; printf("请输入修改的性别! "); scanf("%s",&stu_sex); strcpy(p->stu_sex,stu_sex); break; } case 4: { char stu_college[30]; printf("请输入修改的生日! "); scanf("%s",stu_college); strcpy(p->Birthday,stu_college); break; } case 5: { char stu_profe[30]; printf("请输入修改的年龄! "); scanf("%s",stu_profe); strcpy(p->age,stu_profe); break; } case 6: { char stu_tel[15]; printf("请输入修改的平均分! "); scanf("%s",stu_tel); strcpy(p->Gpa,stu_tel); break; } default: {printf("无此操作! ");break;} }break; } else p=p->next; } if(tage==0)printf("无该学生信息! "); tage=0; printf("修改结束,是否继续修改该学生信息操作:y或Y继续,否者退出! "); fflush(stdin); scanf("%c",&flag); } fflush(stdin); system("cls"); return 0; } int print_student() /*输出学生信息函数*/{ Student *p; p=head; if(head==NULL){printf("无学生信息! ");return 0;} printf("姓名 学号 性别 生日 年龄 平均分 "); printf("=========================================================== "); while(p!=NULL) { printf("%s %ld %s %s %s %s ",p->stu_name,p->stu_num,p->stu_sex,p->Birthday,p->age,p->Gpa); p=p->next; } printf("=========================================================== "); printf("输出结束! "); return 0; } int main() /*主函数*/{ int tage; head=load(); while(1) { printf("44444欢迎进入学生管理系统!44444 "); printf(" 1: 添加学生信息 "); printf(" 2: 删除学生信息 "); printf(" 3: 查找学生信息 "); printf(" 4: 修改学生信息 "); printf(" 5: 输出学生信息 "); printf(" 6: 退出程序 "); printf("4444444444444444444444444444444 "); putchar(10); printf("请输入1-6,其他输入非法! "); scanf("%d",&tage); switch(tage) { case 1:Add_student();break; case 2:del_stu();break; case 3:find_student();break; case 4:ame_student();break; case 5:print_student();break; case 6:save();exit(0);break; default:printf("无此操作 ");break; } } }

c语言编程所用到的全部英语单词?

太多了,兄弟,有while switch for return free if scanf printf gets puts getc putc case define int float double char struct …

c语言编程

#include <string.h>int _tmain(int argc, _TCHAR* argv[]){ char sourceStr[1000] = { }; int len = 0; int i = 0, j = 0; int temp = 0; printf("Please Input The String Which You Want To Encryption: "); gets_s(sourceStr); printf(" "); printf("The Input String is: "); puts(sourceStr); printf(" "); printf("The length of the string is: "); len = strlen(sourceStr); printf("%d ",len); printf(" "); for (;i <= len ;i++) { temp = (int)sourceStr[i]; temp +=3; sourceStr[i] = temp; } printf("After Encryption is: "); for (;j < len;j++) { printf("%c",sourceStr[j]); } printf(" ");return 0;}

C语言编程,题:输入M个不同的字符,从中选出N个字符,输出所有可能的方案。M,N由键盘输入.xie

是随机出现吗???组合问题??

C语言编程,要将100元钱换成1元,2元,5元的零钱.每种钱数大于0,而且为5的倍数,编程计算有多少种换法?

#include<stdio.h>void main(){ int a,b,c,count=0; for(a=5;a<100;a+=5) for(b=5;b<50;b+=5) if((100-a-2*b)%5==0 && ((100-a-2*b)/5)%5==0) count++; printf("%d ",count);}