c語言教師信息
㈠ 教師信息管理系統(c語言)
這個=v=你先建個教師的Class再往裡面填method吧 無外乎就是什麼get set之類的
至於功能界面 你看看能不能用什麼widget之類的插件吧
㈡ 用c語言 編寫 教師信息管理系統
我服了,太不劃算了!
㈢ C語言結構體編程題,求助大神啊
根據題意:
一、教師信息定義為結構體,其成員年月也為結構體(可直接定義成兩個成員變數,本題沒有強制要求),婚姻狀態採用共用體類型。
二、輸入信息直接寫在main函數,實際軟體開發應單獨寫輸入函數,輸入驗證我只寫了性別和婚姻狀態的驗證,其餘成員的輸入驗證需要自己添加。(實際開發,驗證也應單獨寫函數調用)。
三、輸出單獨函數。
#include <stdio.h>
typedef union maType//結婚狀態共用體
{
int type;//0未婚1已婚2離異
}MTE;
typedef struct s_date
{
int year;
int month;
}SDATE;
typedef struct teacher
{
char idNum[20];
char name[20];
int sex;//0女1男
SDATE date;
MTE mtype;
char dtName[100];//工作部門名稱
}TEER;
void printfTinfo(TEER tInfo);
int main()
{
TEER tInfo;
printf("輸入一名教師信息: ");
printf("工資卡號(20個字元):"),scanf("%s",tInfo.idNum);
printf("姓名(20個字元):"),scanf("%s",tInfo.name);
do
printf("性別(0女1男):"),scanf("%d",&tInfo.sex);
while(tInfo.sex!=0 && tInfo.sex!=1);
printf("出生年月(格式:YYYY MM):"),scanf("%d%d",&tInfo.date.year,&tInfo.date.month);
do
printf("婚姻狀態(0未婚1已婚2離異):"),scanf("%d",&tInfo.mtype.type);
while(tInfo.mtype.type!=0 && tInfo.mtype.type!=1 && tInfo.mtype.type!=2);
printfTinfo(tInfo);
return 0;
}
void printfTinfo(TEER tInfo)
{
printf(" ---------------- 輸入的信息為: ");
printf("工資卡號:%s ",tInfo.idNum);
printf("姓名:%s ",tInfo.name);
printf("性別:%s ",tInfo.sex?"男":"女");
printf("出生年月:%04d-%02d ",tInfo.date.year,tInfo.date.month);
printf("婚姻狀態:");
switch(tInfo.mtype.type)
{
case 0:printf("未婚 ");break;
case 1:printf("已婚 ");break;
case 2:printf("離異 ");break;
}
}
㈣ 修改C語言程序,教師信息管理,包括教師號姓名學歷職稱工資電話
你直接加我QQ,我發給你659266172,不清楚的問我
㈤ 用C語言編程實現,從鍵盤上輸入有關教師的姓名,年齡,性別,工資等信息,先將數據存在一個二進制文件...
int main()
{
file *p;
char s[6];
fp=fopen("c:\\aa.txt","wb");
printf("\n請輸入姓名:");
scanf("%s",&s);
fwrite(&s,sizeof(char),strlen(s),fp);
fclose(fp);
}
㈥ 用C語言編出一個簡單的教師信息管理系統。 要求 教師信息包括教師號
什麼時候要東西 我幫你
㈦ C語言課程設計(教師信息管理系統)急求參考!~
看看這個行不行:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct teacher{
char id[10];
char name[30];
char gender;
char nativeplace[30];
char beginwork[11];
char subject[50];
char qualification[20];
char degree[20];
char rank[20];
char office[30];
struct teacher *next;
};
typedef struct teacher Teacher;
Teacher *t=0;
FILE *fp;
char filename[30]="";
void free_memory(){
Teacher *n;
while(t!=0){
n=t->next;
free(t);
t=n;
}
}
void load(){
int c,fail;
Teacher *n;
printf("Do you want to load an existing file or create a new one?\n");
printf("1.Load existing one 2.Create new one\n");
scanf("%d",&c);
if(c==1){
do{
printf("Enter the name of the file: ");
scanf("%s",filename);
fp=fopen(filename,"r");
if(fp==0) {
fail=1;
printf("Cannot open the file, please try again.\n");
}
else fail=0;
}while(fail);
free_memory();
t=0;
while(1){
char id[10],name[30],gender,nativeplace[30],beginwork[11],subject[50],qualification[20],degree[20],rank[20],office[30];
if(fscanf(fp,"%s %s %c %s %s %s %s %s %s %s",id,name,gender,nativeplace,beginwork,subject,qualification,degree,rank,office)==-1) break;
else{
if(t==0){
t=(Teacher *)malloc(sizeof(Teacher));
n=t;
}
else{
n->next=(Teacher *)malloc(sizeof(Teacher));
n=n->next;
}
strcpy(n->id,id);
strcpy(n->name,name);
n->gender=gender;
strcpy(n->nativeplace,nativeplace);
strcpy(n->beginwork,beginwork);
strcpy(n->subject,subject);
strcpy(n->qualification,qualification);
strcpy(n->degree,degree);
strcpy(n->rank,rank);
strcpy(n->office,office);
n->next=0;
}
}
printf("Loading complete\n");
fclose(fp);
}
else if(c==2){
do{
printf("Enter the name of the new file: ");
scanf("%s",filename);
fp=fopen(filename,"w");
if(fp==0) {
fail=1;
printf("Cannot open the file, please try again.\n");
}
else fail=0;
}while(fail);
free_memory();
t=0;
fclose(fp);
char ch[2];
do{
if(t==0){
t=(Teacher *)malloc(sizeof(Teacher));
n=t;
}
else{
n->next=(Teacher *)malloc(sizeof(Teacher));
n=n->next;
}
printf("Enter a new teacher ID: ");
scanf("%s",n->id);
printf("Enter the name of the teacher: ");
scanf("%s",n->name);
printf("Enter the gender of the teacher: ");
scanf("%c",n->gender);
printf("Enter the native place of the teacher: ");
scanf("%s",n->nativeplace);
printf("Enter the time when this teacher began to work: (yyyy/mm/dd) ");
scanf("%s",n->beginwork);
printf("Enter the subject of the teacher: ");
scanf("%s",n->subject);
printf("Enter the qualification of the teacher: ");
scanf("%s",n->qualification);
printf("Enter the degree of the teacher: ");
scanf("%s",n->degree);
printf("Enter the rank of the teacher: ");
scanf("%s",n->rank);
printf("Enter the office of the teacher: ");
scanf("%s",n->office);
n->next=0;
printf("Enter another teacher record? (y/n) ");
scanf("%s",ch);
}while(strcmp(ch,"Y")==0||strcmp(ch,"y")==0);
printf("New teacher data file has been created.\n");
}
}
void display(){
Teacher *n=t;
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
while(n!=0){
printf("%s %s %c %s %s %s %s %s %s %s\n",n->id,n->name,n->gender,n->name,n->beginwork,n->subject,n->qualification,n->degree,n->rank,n->office);
n=n->next;
}
}
void search(int c){
if(t==0){
printf("No teacher data file available.\n");
return;
}
int found=0;
Teacher *p=t;
if(c==1){
char name[30];
printf("Enter the name of the teacher: ");
scanf("%s",name);
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
while(p!=0){
if(strcmp(p->name,name)==0){
printf("%s %s %c %s %s %s %s %s %s %s\n",p->id,p->name,p->gender,p->name,p->beginwork,p->subject,p->qualification,p->degree,p->rank,p->office);
found++;
}
p=p->next;
}
if(found==0) printf("No such teacher exists in the date file.\n");
}
else if(c==2){
char id[10];
printf("Enter the ID of the teacher: ");
scanf("%s",id);
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
while(p!=0){
if(strcmp(p->id,id)==0){
printf("%s %s %c %s %s %s %s %s %s %s\n",p->id,p->name,p->gender,p->name,p->beginwork,p->subject,p->qualification,p->degree,p->rank,p->office);
found++;
}
p=p->next;
}
if(found==0) printf("No such teacher exists in the date file.\n");
}
else if(c==3){
char subject[50];
printf("Enter the subject of the teacher: ");
scanf("%s",subject);
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
while(p!=0){
if(strcmp(p->subject,subject)==0){
printf("%s %s %c %s %s %s %s %s %s %s\n",p->id,p->name,p->gender,p->name,p->beginwork,p->subject,p->qualification,p->degree,p->rank,p->office);
found++;
}
p=p->next;
}
if(found==0) printf("No such teacher exists in the date file.\n");
}
}
void del(char id[]){
Teacher *p1=t;
Teacher *p2;
if(strcmp(t->id,id)==0){t=t->next;free(p1);}
else{
while(p1!=0){
p2=p1;
p1=p1->next;
if(strcmp(p1->id,id)==0){
p2->next=p1->next;
free(p1);
}
}
printf("No such id exists.\n");
}
}
void insert(Teacher *n,int index){
if(index<=0) {n->next=t;t=n;}
else{
Teacher *p=t;
while(p->next!=0&&index>1){
p=p->next;
index--;
}
if(p->next==0) p->next=n;
else{
n->next=p->next;
p->next=n;
}
}
}
void modify(char id[]){
Teacher *p=t;
while(p!=0){
if(strcmp(p->id,id)==0) break;
else p=p->next;
}
if(p==0){
printf("No such record exists.\n");
return;
}
int i;
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
printf("%s %s %c %s %s %s %s %s %s %s\n",p->id,p->name,p->gender,p->name,p->beginwork,p->subject,p->qualification,p->degree,p->rank,p->office);
int c;
printf("What do you want to change?\n");
printf("1.ID 2.Name 3.Gender 4.Native place 5.Begin work 6.Subject 7.Qualification 8.Degree 9.Rank 10.Office\n");
scanf("%d",&c);
if(c==1){
printf("Enter the new ID: ");
scanf("%s",p->id);
}
else if(c==2){
printf("Enter the new name: ");
scanf("%s",p->name);
}
else if(c==3){
printf("Enter the new gender: ");
scanf("%c",p->gender);
}
else if(c==4){
printf("Enter the native place: ");
scanf("%s",p->nativeplace);
}
else if(c==5){
printf("Ente the time this teacher began to work: ");
scanf("%s",p->beginwork);
}
else if(c==6){
printf("Enter the subject: ");
scanf("%s",p->subject);
}
else if(c==7){
printf("Enter the qualification: ");
scanf("%s",p->qualification);
}
else if(c==8){
printf("Enter the degree: ");
scanf("%s",p->degree);
}
else if(c==9){
printf("Enter the rank: ");
scanf("%s",p->rank);
}
else if(c==10){
printf("Enter the office: ");
scanf("%s",p->office);
}
printf("\nThe modified record:\n");
printf("ID Name Gender Native place Begin work Subject Qualification Degree Rank Office\n");
printf("%s %s %c %s %s %s %s %s %s %s\n",p->id,p->name,p->gender,p->name,p->beginwork,p->subject,p->qualification,p->degree,p->rank,p->office);
}
void save(){
if(t==0&&strcmp(filename,"")==0){
printf("No teacher record in store. Load a teacher data file first.\n");
return;
}
fp=fopen(filename,"w");
Teacher *n=t;
while(n!=0){
fprintf(fp,"%s %s %c %s %s %s %s %s %s %s\n",n->id,n->name,n->gender,n->nativeplace,n->beginwork,n->subject,n->qualification,n->degree,n->rank,n->office);
n=n->next;
}
fclose(fp);
printf("File saved.\n");
}
int main(){
int i;
do{
printf("Enter the function you want:\n");
printf("1.Load 2.Add 3.Insert 4.Delete 5.Search 6.Display 7.Modify 8.Save 9.Quit\n");
scanf("%d",&i);
if(i==1){
load();
}
else if(i==2){
if(t==0) printf("No teacher data file loaded yet.\n");
else{
Teacher *n=(Teacher *)malloc(sizeof(Teacher));
printf("Enter a new teacher ID: ");
scanf("%s",n->id);
printf("Enter the name of the teacher: ");
scanf("%s",n->name);
printf("Enter the gender of the teacher: ");
scanf("%c",n->gender);
printf("Enter the native place of the teacher: ");
scanf("%s",n->nativeplace);
printf("Enter the time when this teacher began to work: (yyyy/mm/dd) ");
scanf("%s",n->beginwork);
printf("Enter the subject of the teacher: ");
scanf("%s",n->subject);
printf("Enter the qualification of the teacher: ");
scanf("%s",n->qualification);
printf("Enter the degree of the teacher: ");
scanf("%s",n->degree);
printf("Enter the rank of the teacher: ");
scanf("%s",n->rank);
printf("Enter the office of the teacher: ");
scanf("%s",n->office);
n->next=0;
int c=0;
Teacher *p=t;
while(p!=0){
c++;
p=p->next;
}
insert(n,c);
}
}
else if(i==3){
if(t==0) printf("No teacher data file loaded yet.\n");
else{
Teacher *n=(Teacher *)malloc(sizeof(Teacher));
printf("Enter a new teacher ID: ");
scanf("%s",n->id);
printf("Enter the name of the teacher: ");
scanf("%s",n->name);
printf("Enter the gender of the teacher: ");
scanf("%c",n->gender);
printf("Enter the native place of the teacher: ");
scanf("%s",n->nativeplace);
printf("Enter the time when this teacher began to work: (yyyy/mm/dd) ");
scanf("%s",n->beginwork);
printf("Enter the subject of the teacher: ");
scanf("%s",n->subject);
printf("Enter the qualification of the teacher: ");
scanf("%s",n->qualification);
printf("Enter the degree of the teacher: ");
scanf("%s",n->degree);
printf("Enter the rank of the teacher: ");
scanf("%s",n->rank);
printf("Enter the office of the teacher: ");
scanf("%s",n->office);
n->next=0;
int c;
printf("Enter the index: ");
scanf("%d",&c);
insert(n,c);
}
}
else if(i==4){
char id[10];
printf("Enter the id: ");
scanf("%s",id);
del(id);
}
else if(i==5){
int i;
printf("Choose the way you want to search: ");
printf("1.Name 2.ID 3.Subject\n");
scanf("%d",&i);
search(i);
}
else if(i==6){
display();
}
else if(i==7){
char id[10];
printf("Enter the ID of the record you want to change: ");
scanf("%s",id);
modify(id);
}
else if(i==8){
save();
}
else if(i==9){
Teacher *p;
while(t!=0){
p=t->next;
free(t);
t=p;
}
break;
}
}while(1);
return 0;
}
㈧ 求C語言大神幫忙編寫《教師信息管理系統》 不要用C++ 也沒有指針的
不用指針還有點難辦啊,總不能全都放在結構體數組里吧。