标题:请问大神这个程序哪里不对了,dos窗口提示xxx.exe程序已停止工作
只看楼主
aotuyan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-11-3
结帖率:0
已结贴  问题点数:20 回复次数:4 
请问大神这个程序哪里不对了,dos窗口提示xxx.exe程序已停止工作
#include "stdio.h"
#include "string.h"

#define  M 2
#define  W 2
#define  ns 2
#define  na 2

int main()
{
   
    struct Athlete
    {   
        int item;
        int school;
        int place;
        char name[20];
        int score;  
        char sex;
    };
   
    struct Athlete ath[na];

    for(int i=0;i<na;i++)
    {
        printf("          òÔÏÂêÇμú%d¸öÔ˶ˉÔ±DÅÏ¢μÄêäèë\n",i+1);
        printf("ÇëêäèëÔ˶ˉÔ±DÔ±e±êÖ¾£¨ÄDm/Å®w£©:");
        scanf("%c",&ath[i].sex);
        getchar();rewind(stdin);
        printf("ÇëêäèëÔ˶ˉÔ±2μóÏîÄ¿±àoÅ:");
        scanf("%d",&ath[i].item);
        printf("ÇëêäèëÔ˶ˉÔ±ËùêôѧD£±àoÅ:");
        scanf("%d",&ath[i].school);
        printf("ÇëêäèëÔ˶ˉÔ±ÏîÄ¿ÅÅÃû:");
        scanf("%d",&ath[i].place);
        printf("ÇëêäèëÔ˶ˉÔ±DÕÃû£¨2»¶àóú20¸ö×Ö·û£©:");
        scanf("%s",ath[i].name);
        printf("\n");
        if(ath[i].place==1)
            ath[i].score=5;
        else if(ath[i].place==2)
            ath[i].score=3;
        else if(ath[i].place==3)
            ath[i].score=2;
        else
            ath[i].score=0;
    }
        
    for(int j=1;j<=ns;j++)
    {
        printf("**********************ѧD£±àoÅ%d***************************\n",j);
        printf("        ÏîÄ¿oÅ       Ãû′Π      Ô˶ˉÔ±DÕÃû      μ÷֠ \n");
        for(int i=0;i<na;i++)
        {
            if(ath[i].school==j && ath[i].sex=='m')
            {
                for(int k=1;k<=M;k++)
                {
                    if(ath[i].item==k)
                    printf("     ÄD×ó    %d     %d      %s     %d\n",k,ath[i].place,ath[i].name[20],ath[i].score);
                }
            }

            else if(ath[i].school==j && ath[i].sex=='w')
            {
                for(int k=1;k<=W;k++)
                {   
                    if(ath[i].item==k)
                    printf("     Å®×ó    %d     %d      %s     %d\n",k,ath[i].place,ath[i].name[20],ath[i].score);
                }
            }
        }
    }
return 0;
}
搜索更多相关主题的帖子: include school 
2015-11-03 20:50
aotuyan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-11-3
得分:0 
#include "stdio.h"
#include "string.h"

#define  M 2
#define  W 2
#define  ns 2
#define  na 2

int main()
{
   
    struct Athlete
    {   
        int item;
        int school;
        int place;
        char name[20];
        int score;  
        char sex;
    };
   
    struct Athlete ath[na];

    for(int i=0;i<na;i++)
    {
        printf("          以下是第%d个运动员信息的输入\n",i+1);
        printf("请输入运动员性别标志(男m/女w):");
        scanf("%c",&ath[i].sex);
        getchar();rewind(stdin);
        printf("请输入运动员参加项目编号:");
        scanf("%d",&ath[i].item);
        printf("请输入运动员所属学校编号:");
        scanf("%d",&ath[i].school);
        printf("请输入运动员项目排名:");
        scanf("%d",&ath[i].place);
        printf("请输入运动员姓名(不多于20个字符):");
        scanf("%s",ath[i].name);
        printf("\n");
        if(ath[i].place==1)
            ath[i].score=5;
        else if(ath[i].place==2)
            ath[i].score=3;
        else if(ath[i].place==3)
            ath[i].score=2;
        else
            ath[i].score=0;
    }
        
    for(int j=1;j<=ns;j++)
    {
        printf("**********************学校编号%d***************************\n",j);
        printf("        项目号       名次       运动员姓名      得分  \n");
        for(int i=0;i<na;i++)
        {
            if(ath[i].school==j && ath[i].sex=='m')
            {
                for(int k=1;k<=M;k++)
                {
                    if(ath[i].item==k)
                    printf("     男子    %d     %d      %s     %d\n",k,ath[i].place,ath[i].name[20],ath[i].score);
                }
            }

            else if(ath[i].school==j && ath[i].sex=='w')
            {
                for(int k=1;k<=W;k++)
                {   
                    if(ath[i].item==k)
                    printf("     女子    %d     %d      %s     %d\n",k,ath[i].place,ath[i].name[20],ath[i].score);
                }
            }
        }
    }
return 0;
}
2015-11-03 20:51
aotuyan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-11-3
得分:0 
#include "stdio.h"


int main()
{
   
    struct Athlete
    {   
        int item;
        int school;
        int place;
        char name[20];
        int score;  
        char sex;
    };
   
    struct Athlete ath;

   
        printf("ÇëêäèëÔ˶ˉÔ±DÔ±e±êÖ¾£¨ÄDm/Å®w£©:");
        scanf("%c",&ath.sex);
        getchar();rewind(stdin);
        printf("ÇëêäèëÔ˶ˉÔ±2μóÏîÄ¿±àoÅ:");
        scanf("%d",&ath.item);
        printf("ÇëêäèëÔ˶ˉÔ±ËùêôѧD£±àoÅ:");
        scanf("%d",&ath.school);
        printf("ÇëêäèëÔ˶ˉÔ±ÏîÄ¿ÅÅÃû:");
        scanf("%d",&ath.place);
        printf("ÇëêäèëÔ˶ˉÔ±DÕÃû£¨2»¶àóú20¸ö×Ö·û£©:");
        scanf("%s",ath.name);
        printf("\n");
        if(ath.place==1)
            ath.score=5;
        else if(ath.place==2)
            ath.score=3;
        else if(ath.place==3)
            ath.score=2;
        else
            ath.score=0;
    printf("%s",ath.school);
return 0;
}
连这个也是一样的问题
2015-11-03 21:05
aotuyan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2015-11-3
得分:0 

 #include "stdio.h"

/*#define  M 2
#define  W 2
#define  ns 2
#define  na 2

int main()
{
    struct Athlete
    {   
        int item;
        int school;
        int place;
        char name[20];
        int score;  
        char sex;
    };
   
    struct Athlete ath;
        printf("请输入运动员性别标志(男m/女w):");
        scanf("%c",&ath.sex);
        getchar();rewind(stdin);
        printf("请输入运动员参加项目编号:");
        scanf("%d",&ath.item);
        printf("请输入运动员所属学校编号:");
        scanf("%d",&ath.school);
        printf("请输入运动员项目排名:");
        scanf("%d",&ath.place);
        printf("请输入运动员姓名(不多于20个字符):");
        scanf("%s",ath.name);
        printf("\n");
        if(ath.place==1)
            ath.score=5;
        else if(ath.place==2)
            ath.score=3;
        else if(ath.place==3)
            ath.score=2;
        else
            ath.score=0;
    printf("%s",ath.school);
return 0;
}
怎么老是乱码
2015-11-03 21:07
pycansi
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:5
帖 子:418
专家分:1060
注 册:2012-7-26
得分:20 
回复 4楼 aotuyan
检查 printf


莫问前尘有愧,但求今生无悔
2015-11-04 10:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-458852-1-1.html




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

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