猿问

请帮我看一下输入怎么没有用的

#include <stdio.h>

#include<string.h>

#include<stdlib.h>  

#define TEACHERCOUNT 3 //定义学生人数数组大小


 struct str_teacher

{

char number[20]; // 工号

char name[20]; // 姓名

char phone[20]; // 联系方式

float baseSalary; // 基本工资

};

typedef struct str_teacher Teacher;

void outputteacher(Teacher teacher);

void inputteacher( Teacher   * teacher);

void inputteachers( Teacher teachers[], int *count  );

int findteacherByNumber(Teacher teachers[] , char number[], int count )

{

int i=0;

for(i=0;i<count;i++)

{

if(strcmp(teachers[i].number,number)==0)

return i ;

}

return -1;

}

void  main ()

{

int choice;

Teacher    teachers   [TEACHERCOUNT];

int count;

int i;

int index;

char number[20];


   printf("欢迎使用学生信息管理系统!\n");

do{


printf("1.输入2.输出3.插入4.删除5.修改6.查找7.排序8.保存9.加载0.退出\n");

printf("请选择:");

scanf("%d",&choice);

switch(choice)

{

case 1:// 输入

inputteachers( teachers, &count );

break;

break;

case 2: //输出

printf("工号\t姓名\t联系方式\t基本工资\t个人所得税\t实发工资\n");

for(i=0;i<count;i++)

{

outputteacher( teachers[i]);

}


break;

case 3:// 插入

printf("请输入要插入的位置:");

scanf(" %d",&index);

for(i=0;i>=index;i++)

{

teachers[i]=teachers[i-1];

}

inputteacher(&teachers[i]);

count++;


break;

case 4:  //删除

printf("请输入要删除的学号:");

scanf(" %s",number);

index=findteacherByNumber(teachers,number,count)+1;

if(index<0)

printf("未找到该学号。\n");

else

{

for(i=index-1;i<count-1;i++)

{

teachers[i]=teachers[i+1];

}

count--;

}

break;

case 5: // 修改


break;

case 6:  //查找


break;

case 7: // 排序


break;

case 8 : // 保存



break;

case 9: // 加载

break;


case 0:

default:

break;

}

}while(choice!=0);





}

void inputteacher(Teacher *  pTeacher)

{



printf("请输入学号:");

scanf(" %s",pTeacher->number);

printf("请输入姓名:");

scanf(" %s",pTeacher->name);

printf("请输入联系方式:");

scanf(" %s",pTeacher->phone);

printf("请输入基本工资:");

scanf("%.2f",pTeacher->baseSalary);

}

void inputteachers(Teacher  teachers[], int *count )

{

int i;

char choice;

for(i=0;i<TEACHERCOUNT;i++)

{

inputteacher(&teachers[i]);

(*count)++;

printf("是否继续(Y/N):\n");

scanf(" %c",&choice);

if(choice!='Y' && choice!='y')

break;

}

}

void outputteacher(Teacher Teacher)

{

printf("%s\t",Teacher.number);//输出学号

printf("%s\t",Teacher.name);

printf("%s\t",Teacher.phone);// 输出姓名

printf("%s\t",Teacher.baseSalary); // 输出性别

}


慕粉1401006384
浏览 1217回答 2
2回答

慕粉1103124771

你这个是后台的啊,我只会前端的哦

望远

 1.主函数里变量count没有初始化为02.输入语句scanf没有精度控制。      //scanf("%.2f",pTeacher->baseSalary);非法                   
随时随地看视频慕课网APP
我要回答