| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 448 人关注过本帖
标题:求高手调试,找找有什么问题!
取消只看楼主 加入收藏
狼治天下
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
求高手调试,找找有什么问题!
/*  HELLO.C -- Hello, world */

#include "stdio.h"
#include "conio.h"
#include "math.h"
struct a
{
    int xh;
    char xm[10];
    int qz;
    int qm;
    int zp;
};
/*定义数组*/
int add(struct a z[50],int i)
{
    int a,b;
    printf("add number\n");
    scanf("%d",&a);
    for(b=1;b<=a;b++)
    {printf("xh xm qz qm \n");
    scanf("%d %s %d %d",&z[b].xh,&z[b].xm,&z[b].qz,&z[b].qm);
    z[b].zp=z[b].qz+z[b].qm;
    }
    i=i+1;
    return i;
}
/*添加记录*/
int delete(struct a z[50],int i)
{
    int j,k,l;
    printf("delete xh");
    scanf("%d",&k);
    for(j=0;j<=i;j++)
      if(k==z[j].xh)
        l=j;
    for(;l<=i;l++)
      z[l]=z[l+1];
    i--;
    return i;
}
/*删除记录*/
void sort(struct a z[50],int i)
{
    int j,k;
    struct a a;
    for(j=0;j<i;j++)
      for(k=j+1;k<=i;k++)
        if(z[j].zp>z[k].zp)
        {
           a=z[j];
           z[j]=z[k];
           z[k]=a;
        }
}
/*记录排序*/
int top(struct a z[50],int i)
{
  int j,k,max=0;
  for(j=0;j<=i;j++)
    if(z[j].zp>max)
      max=z[j].zp;

  printf("the top is %d",max);

}
/*最高分*/
int low(struct a z[50],int i)
{
  int j,k,min;
  for(j=0;j<=i;j++)
    if(z[j].zp<z[j+1].zp)
      min=z[j].zp;
    else
      min=z[j+1].zp;
  printf("the low is %d",min);
}
/*最低分*/
int  ave(struct a z[50],int i)
{ int j,s=0;
  for(j=0;j<=i;j++)
    {
       s=s+z[j].zp;

    }

  printf("the average is%d",s/i);

}
/*平均分*/
void pass(struct a  z[50],int i)
{
  int j,k;
  for(j=0;j<=i;j++)
   {
     if(z[j].zp>=60)
      k++;

   }
   return k;
}
/*及格率*/
void  name(struct a z[50],int i)
 {  int j,k;
    printf("please input name:");
    scanf("%s",&k);
    for(j=0;j<=i;j++)
      {
        if(z[j].xm==k)
           printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,
           z[j].zp=z[j].qz*0.3+z[j].qm*0.7);
        else
           printf("error!") ;

      }

 }

 /*按姓名查询*/
void number(struct a z[50],int i)
 {  int j,k;
    printf("please input number:");
    scanf("%d",&k);
    for(j=0;j<=i;j++)
      {
        if(z[j].xh==k)
           printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,
           z[j].zp=z[j].qz*0.3+z[j].qm*0.7);
        else
           printf("error!") ;

      }

 }
 /*按学号查询*/
main()
{   struct a z[50];
    int a,b,i;
    char c,w;




    printf("********************************************************************************");
    printf("\n");
    printf("                               1.Grade Management                               ");
    printf("\n");
    printf("                               2.Results Summary                                ");
    printf("\n");
    printf("                               3.Search Results                                 ");
    printf("********************************************************************************");

    printf("\n\n");
    printf("                           qing xuan ze:");
    printf("\n\n\n");
    printf("qing xuan ze  :  ");
    scanf("%d",&a);
    if(a==1)
     { clrscr();
       printf("                          ****************************\n\n");
       printf("***************************    1.Grade Management    ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Add stu_info");
       printf("%s\n\n\n","                               2. Delete stu_info");
       printf("%s\n\n\n","                               3. Sort stu_info");
       printf("%s\n\n\n","                               4. return");
       printf("qing xuan ze :  ");
       getchar();
       scanf("%c",&b);
       if(b==1)
          i=add(&z,i);
       if(b==2)
          i=delete(&z,i);
       if(b==3)
           sort(&z,i);
       getchar();
         
      }
     if(a==2)
       { clrscr();
       printf("                          ****************************\n\n");
       printf("***************************    2.Results Summary     ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Check top grade");
       printf("%s\n\n\n","                               2. Check low grade");
       printf("%s\n\n\n","                               3. Check all the average grade");
       printf("%s\n\n\n","                               4. Check the pass grade");
       printf("%s\n\n\n","                               5. return");
       printf("qing xuan ze  :  ");
       getchar();
       scanf("%c",&b);
       if(b==1)
        i=top(&z,i);
       if(b==2)
        i=low(&z,i);
       if(b==3)
        i=ave(&z,i);
       if(b==4)
       pass(&z,i);
       getchar();
      }
     if(a==3)
     { clrscr();
       printf("                          ****************************\n\n");
       printf("***************************    3.Search Results      ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Check the grade by name");

       printf("%s\n\n\n","                               2. Check the grade by number");
       printf("%s\n\n\n","                               3. return");
       printf("qing xuan ze  :  ");
       getchar();
       scanf("%c",&b);
       if(b==1)
        name(&z,i);
       if(b==2)
        number(&z,i);
       getchar();


      }



}

搜索更多相关主题的帖子: 记录 include number return world 
2011-06-20 21:12
狼治天下
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
收藏
得分:0 
/*  HELLO.C -- Hello, world */

#include "stdio.h"       /*最低分和按姓名查找不对*/
#include "conio.h"
#include "math.h"
struct a
{
    int xh;
    char xm[10];
    int qz;
    int qm;
    int zp;
};
/*定义数组*/
int add(struct a z[50],int i)
{
    int a,b;
    printf("input number\n");
    scanf("%d",&a);
    for(b=1;b<=a;b++)
    {printf("xuehao xingming qizhong qimo\n");
    scanf("%d %s%d %d",&z[i+b].xh,&z[i+b].xm,&z[i+b].qz,&z[i+b].qm);
    z[i+b].zp=z[i+b].qz*0.3+z[i+b].qm*0.7;}
    i=i+a;
    return i;
}
/*添加记录*/
int delete(struct a z[50],int i)
{
    int j,k,l;
    printf("delete xh");
    scanf("%d",&k);
    for(j=0;j<=i;j++)
      if(k==z[j].xh)
        l=j;
    for(;l<=i;l++)
      z[l]=z[l+1];
    i--;
    return i;
}
/*删除记录*/
void sort(struct a z[50],int i)
{
    int j,k;
    struct a a;
    for(j=0;j<i;j++)
      for(k=j+1;k<=i;k++)
        if(z[j].zp>z[k].zp)
        {
           a=z[j];
           z[j]=z[k];
           z[k]=a;
        }
}
/*记录排序*/
void top(struct a z[50],int i)
{
  int j,k;
  for(j=0;j<=i;j++)
    if(z[j].zp>z[0].zp)
      z[0].zp=z[j].zp;
}
/*最高分*/
void low(struct a z[50],int i)
{
  int j,k;
  z[0].zp=z[1].zp;
  for(j=2;j<=i;j++)
    if(z[j].zp<z[0].zp)
      z[0].zp=z[j].zp;

}
/*最低分*/
void ave(struct a z[50],int i)
{ int j;
  for(j=1;j<=i;j++)
    {
     z[0].zp=z[0].zp+z[j].zp;

    }

    z[0].zp=z[0].zp/i;

}
/*平均分*/
float pass(struct a  z[50],int i)
{
  int j;
  float k=0;
  for(j=1;j<=i;j++)
   {
     if(z[j].zp>=60)
      k++;

   }
   return k;
}
/*及格率*/
void  name(struct a z[50],int i)
 {  int j,l=0;
    char k[10];
    printf("please input name:");
    scanf("%s",&k);
    for(j=0;j<=i;j++)
      {
        if(z[j].xm==k)
           printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,z[j].zp);
         l=1;
      }
       if(l==0)
      printf("error!") ;
 }

 /*按姓名查询*/
void number(struct a z[50],int i)
 {  int j,k,l=0;
    printf("please input number:");
    scanf("%d",&k);
    for(j=1;j<=i;j++)
      {
        if(z[j].xh==k)
           printf("%d %s %d %d %d",z[j].xh,z[j].xm,z[j].qz,z[j].qm,z[j].zp);
         l=1;
      }
       if(l==0)
      printf("error!") ;

 }
 /*按学号查询*/
main()
{   struct a z[50]={{0}};
    int a,b,i=0;
    float d;
    char c,w;


    do{



    printf("********************************************************************************");
    printf("\n");
    printf("                               1.Grade Management                               ");
    printf("\n");
    printf("                               2.Results Summary                                ");
    printf("\n");
    printf("                               3.Search Results                                 ");
    printf("********************************************************************************");
    printf("\n\n");
    printf("                           qing xuan ze:");
    printf("\n\n\n");
    printf("qing xuan ze  :  ");
    scanf("%d",&a);
    if(a==1)
     {
       printf("                          ****************************\n\n");
       printf("***************************    1.Grade Management    ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Add stu_info");
       printf("%s\n\n\n","                               2. Delete stu_info");
       printf("%s\n\n\n","                               3. Sort stu_info");
       printf("%s\n\n\n","                               4. return");
       printf("qing xuan ze :  ");

          scanf("%d",&b);
          if(b==1)
            i=add(&z,i);
          if(b==2)
            i=delete(&z,i);
          if(b==3)
            sort(&z,i);
      }
     if(a==2)
       {
       printf("                          ****************************\n\n");
       printf("***************************    2.Results Summary     ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Check top grade");
       printf("%s\n\n\n","                               2. Check low grade");
       printf("%s\n\n\n","                               3. Check all the average grade");
       printf("%s\n\n\n","                               4. Check the pass grade");
       printf("%s\n\n\n","                               5. return");
       printf("qing xuan ze  :  ");
       scanf("%d",&b);
       if(b==1)
       { top(&z,i);
       printf("%d\n",z[0].zp);}
       if(b==2)
        {low(&z,i);
       printf("%d\n",z[0].zp);}
       if(b==3)
        {ave(&z,i);
       printf("%d\n",z[0].zp);}
       if(b==4)
       {d=pass(&z,i);
       d=d/i;
       printf("%f\n",d);
       }}
     if(a==3)
     { clrscr();
       printf("                          ****************************\n\n");
       printf("***************************    3.Search Results      ***************************\n");
       printf("                          ****************************\n\n");
       printf("\n\n\n\n");
       printf("%s\n\n\n","                               1. Check the grade by name");

       printf("%s\n\n\n","                               2. Check the grade by number");
       printf("%s\n\n\n","                               3. return");
       printf("qing xuan ze  :  ");
       scanf("%d",&b);
       if(b==1)
        name(&z,i);
       if(b==2)
        number(&z,i);


      }

  /*        for(a=1;a<=i;a++)
      printf("%d %s %d %d %d\n",z[a].xh,z[a].xm,z[a].qz,z[a].qm,z[a].zp);
   */
    printf("shi fou ji xu:(y or n )\n");
    scanf("%s",&c);
    }while(c=='y'||c=='Y');
      getch();
}
这是第二次修改的,就还有两处地方修改不对......
2011-06-20 23:05
狼治天下
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
收藏
得分:0 
回复 2楼 pkwangxinjun
刚修改了半天,还是有不对的地方,能否解决,谢谢
2011-06-20 23:06
狼治天下
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
收藏
得分:0 
回复 3楼 gao_guai
就是用Tc写的程序
2011-06-20 23:07
狼治天下
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
收藏
得分:0 
回复 7楼 ppfly
恩,恩,一定。。。。谢谢
2011-06-23 22:18
快速回复:求高手调试,找找有什么问题!
数据加载中...
 
   



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

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