| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 362 人关注过本帖
标题:发个自己写的程序上来求指导
只看楼主 加入收藏
andyhu1a
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-1-2
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
发个自己写的程序上来求指导
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<conio.h>
#define stud struct student
   

 stud
{
  char name[20];
  char sex;
  long number;
  int math;
  int c;
  int english;
}stu;
void Input(stud *p)
{
  scanf("%s\n",stu.name);
  scanf("%s\n",&stu.sex);
  scanf("%d\n",&stu.number);
  scanf("%d\n",&stu.math);
  scanf("%d\n",&stu.c);
  scanf("%d\n",&stu.english);
}
void showstu(stud *p)
{
printf("%s\n",stu.name);
  printf("%s\n",stu.sex);
 printf("%d\n",stu.number);
  printf("%d\n",stu.math);
  printf("%d\n",stu.c);
  printf("%d\n",stu.english);
}
void Output(stud *p)
{
FILE *fp;
stud stu;
if((fp=fopen("file.1","rb"))==NULL)
{
    printf("eroor could not open");
    exit(0);
}
while(!feof(fp))
{
    showstu(&stu);
fread((char *)&stu,sizeof(stud),1,fp)
}
void addstu()
{
  FILE *fp;
  stud stu;
  if(fp=fopen("file.1","wb")=NULL)
  {
  printf("file open error");
  exit(0);
  }
intput(&stu);
fwrite((char *)&stu,sizeof(stud),1,fp)
fcolse(fp);
}
void Information()
{
  int a,i,k;
  char j[20];
 stud studd[77];
FILE *fp;
if(fp=fopen("file.1","rb")=NULL)
  {
  printf("file open error");
  exit(0);
  }
fread(studd,sizeof(stud),77,fp)
    fclose(fp);
 printf("***********Use Name(1)**********\n");
  printf("***********Use Number(2)*********\n");
  scanf("%d\n",a);
if(a==1)
{
 scanf("%s\n",&j);
 for(i=0;i<77;i++)
 {
   if(strcmp(j,stu[i].name)==0)
   printf("%s\t%s\t%ld\t%d\t%d\t%d\t",studd[i].name,studd[i].sex,studd[i].number,studd[i].math,studd[i].c,studd[i].english);
 }
}
if(a==2)
 {
   scanf("%d\n",k);
   for(i=0;i<77;i++)
   {
     if(st u[i].number==k)
     printf("%s\t%s\t%ld\t%d\t%d\t%d\t",studd[i].name,studd[i].sex,studd[i].number,studd[i].math,studd[i].sub.c,studd[i].english);
    }
  }      
if(a!=(1||2))
printf("***********Error,Sign Out**************\n");
}
void Summation()
{    int a,b,j,k,i,sum,sum1,sum2,sum3;
 printf("********Personal(1)*********\n");
 printf("********Subject(2)********\n");
 scanf("%d\n",a);
 if(a==1)
 {   
      printf("*********Please Input Serial Number**********\n");
      scanf("%d",i);   
   sum=(studd[i].math+studd[i].c+studd[i].english);
   printf("%s,%d\n",studd[i].name,sum);
  }
 if(a==2)
 {
      printf("*********math(1)***********\n");
      printf("*********c(2)***********\n");
      printf("*********english(3)***********\n");
   scanf("%d\n",b);
   if(b==1)
       {
            for(j=0;j<77;j++)
            sum1=sum+studd[i].math;
            printf("math of sum=%d\n",sum);
        }
        if(b==2)
       {
            for(j=0;j<77;j++)
            sum2=sum+studd[i].c;
            printf("c of sum=%d\n",sum);
        }
        if(b==3)
       {
            for(j=0;j<77;j++)
            sum3=sum+studd[i].english;
            printf("english of sum=%d\n",sum);
        }
  }
  if(a!=(1||2))
  printf("***********Error,Sign Out**************\n");        
}
void Average()
{
    stud studd[77];
    int a,b,j,k,i,sum,sum1,sum2,sum3;
 float average,average1,average2,average3;
 printf("********Personal(1)*********\n");
 printf("********Subject(2)********\n");
 scanf("%d\n",a);
 if(a==1)
 {   
      printf("*********Please Input Serial Number**********\n");
      scanf("%d",i);   
   sum=(stu[i].sub.math+studd[i].sub.c+studd[i].english);
   average=(sum/3);
   printf("%s,%f\n",stu[i].name,average);
  }
 if(a==2)
 {
      printf("*********math(1)***********\n");
      printf("*********c(2)***********\n");
      printf("*********english(3)***********\n");
   scanf("%d\n",b);
   if(b==1)
       {
            for(j=0;j<77;j++)
            sum1=sum+stu[i].sub.math;
            average1=(sum1/3);
            printf("math of average=%f\n",average1);
        }
        if(b==2)
       {
            for(j=0;j<77;j++)
            sum2=sum+studd[i].c;
            average2=(sum2/3);
            printf("c of average=%f\n",average2);
        }
        if(b==3)
       {
            for(j=0;j<77;j++)
            sum3=sum+studd[i].english;
            average3=(sum3/3);
            printf("english of average=%f\n",average3);
        }
  }
  if(a!=(1||2))
  printf("***********Error,Sign Out**************\n");        
}
int main()
{  
  int i,j;
  i=1;
printf("welcome to\n");
printf("***********Input(1)***********\n");
printf("***********Output(2)***********\n");
printf("***********Find Information(3)***********\n");
printf("***********Scroe Summation(4)***********\n");
printf("***********Score Average(5)***********\n");
printf("***********Sign Out(6)*************\n");
printf("**Be Careful:You Must First Input**\n");
do
{
  scanf("%d\n",&j);
  switch(j)
 {
  case 1: {Input();printf("**********complete************\n");break;}
  case 2: {Output();printf("**********complete************\n");break;}
  case 3: {Information();printf("**********complete************\n");break;}
  case 4: {Summation();printf("**********complete************\n");break;}
  case 5: {Average();printf("**********complete************\n");break;}
  case 6: {printf("**********Thank You To Use************\n");break;}
 }
}while(j!=6);
return 0;
}
搜索更多相关主题的帖子: english include number 
2012-01-03 13:26
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:5 
看了第一个input函数就没再往下看

总有那身价贱的人给作业贴回复完整的代码
2012-01-03 15:09
vandychan
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
等 级:贵宾
威 望:18
帖 子:2296
专家分:6418
注 册:2010-8-20
收藏
得分:5 
好乱

到底是“出来混迟早要还”还是“杀人放火金腰带”?
2012-01-03 15:28
快速回复:发个自己写的程序上来求指导
数据加载中...
 
   



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

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