| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 576 人关注过本帖
标题:新手想问问问题出在哪了
只看楼主 加入收藏
haoliliang88
Rank: 1
等 级:新手上路
帖 子:26
专家分:3
注 册:2010-3-12
结帖率:100%
收藏
 问题点数:0 回复次数:8 
新手想问问问题出在哪了
这是file.h文件
#include<stdio.h>
#include<file2.h>
struct month
{int number;
char english_name;
int days;
}mon[12];
enum english_month{January,February,Marcy,April,May,June,July,August,September,October,November,December};
enum month_englishname;
month_englishname=Februar
这是file.h的文件
void main()
{int i;
for(i=1;i<=12;i++)
{mon[i-1].number=i;
switch(month_englishname)
{case January:mon[i-1].english_name=January;
break;
case February:mon[i-1].english_name=February;
break;
case Marcy:mon[i-1].english_name=Marcy;
break;
case April:mon[i-1].english_name=April;
break;
case May:mon[i-1].english_name=May;
break;
case June:mon[i-1].english_name=June;
break;
case July:mon[i-1].english_name=July;
break;
case August:mon[i-1].english_name=August;
break;
case September:mon[i-1].english_name=September;
break;
case October:mon[i-1].english_name=October;
break;
case November:mon[i-1].english_name=November ;
break;
case December:mon[i-1].english_name=December;
break;
}
month_englishname++;
if(i%2==0)
mon[i-1].days=31;
else mon[i-1].days=30;
mon[1].days=28or29;
printf("月份  英语名  天数\n");
printf("%d\t\t%s\t\t%s\n",mon[i-1].number,mon[i-1].english_name,mon[i-1].days);}}
请问大家这个程序问题出在哪了?
搜索更多相关主题的帖子: void include number 
2010-03-16 23:44
haoliliang88
Rank: 1
等 级:新手上路
帖 子:26
专家分:3
注 册:2010-3-12
收藏
得分:0 
#include<stdio.h>
#include<file2.h>
struct month
{int number;
char english_name;
int days;
}mon[12];
enum english_month{January,February,Marcy,April,May,June,July,August,September,October,November,December};
enum month_englishname;
month_englishname=Februar
void main()
{int i;
for(i=1;i<=12;i++)
{mon[i-1].number=i;
switch(month_englishname)
{case January:mon[i-1].english_name=January;
break;
case February:mon[i-1].english_name=February;
break;
case Marcy:mon[i-1].english_name=Marcy;
break;
case April:mon[i-1].english_name=April;
break;
case May:mon[i-1].english_name=May;
break;
case June:mon[i-1].english_name=June;
break;
case July:mon[i-1].english_name=July;
break;
case August:mon[i-1].english_name=August;
break;
case September:mon[i-1].english_name=September;
break;
case October:mon[i-1].english_name=October;
break;
case November:mon[i-1].english_name=November ;
break;
case December:mon[i-1].english_name=December;
break;
}
month_englishname++;
if(i%2==0)
mon[i-1].days=31;
else mon[i-1].days=30;
mon[1].days=28or29;
printf("月份  英语名  天数\n");
printf("%d\t\t%s\t\t%s\n",mon[i-1].number,mon[i-1].english_name,mon[i-1].days);}}
请问大家这个程序问题出在哪了?
2010-03-17 10:02
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
收藏
得分:0 
搞这么长 还不给分
2010-03-17 10:19
mghxz252
Rank: 2
等 级:论坛游民
帖 子:40
专家分:60
注 册:2010-1-18
收藏
得分:0 
我改了一下,能运行出来,但不能显示月份的英文名,楼主再改一下,完了的发记得发出来。
程序代码:
#include <stdio.h>
struct month
{int number;
char english_name;
int days;
}mon[12];
enum english_month{January,February,Marcy,April,May,June,July,August,September,October,November,December};
int main(void)
{int i;
for(i=1;i<=12;i++)
{char month_englishname;
switch(month_englishname)
{
case January:mon[i-1].english_name=January;
break;
case February:mon[i-1].english_name=February;
break;
case Marcy:mon[i-1].english_name=Marcy;
break;
case April:mon[i-1].english_name=April;
break;
case May:mon[i-1].english_name=May;
break;
case June:mon[i-1].english_name=June;
break;
case July:mon[i-1].english_name=July;
break;
case August:mon[i-1].english_name=August;
break;
case September:mon[i-1].english_name=September;
break;
case October:mon[i-1].english_name=October;
break;
case November:mon[i-1].english_name=November ;
break;
case December:mon[i-1].english_name=December;
break;
}
month_englishname++;
if(i%2==0)
mon[i-1].days=31;
else mon[i-1].days=30;
printf("月份  英语名  天数\n");
printf("%d\t\t%d\t\t%d\n",i,mon[i-1].english_name,mon[i-1].days);
}
return 0;
}
2010-03-17 15:51
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:216
帖 子:1509
专家分:9241
注 册:2010-3-16
收藏
得分:0 
回复 楼主 haoliliang88
程序代码:
#include <stdio.h>
#include <string.h>

struct month
{
    int number;
    char english_name[15];
    int days;
} mon[12];

int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
char enName[12][15]={"January","February","Marcy","April","May","June","July","August","September","October","November","December",};

int main(void)
{
    int i;
    printf(" 月份\t 天数\t 英语名  \n");
    for(i=0; i<12; i++)
    {
        mon[i].number=i+1;
        strcpy(mon[i].english_name,enName[i]);
        mon[i].days=days[i];    
        printf("%4d\t%4d\t%s\n",mon[i].number,mon[i].days,mon[i].english_name);
    }
    return 0;
}



enum 虽然是英文名字,但是真实的值是从0开始计算的。因此不能用于显示月份名。
既然mon的number存储了月份,那就直接输出,没必要用i。
2010-03-17 17:44
haoliliang88
Rank: 1
等 级:新手上路
帖 子:26
专家分:3
注 册:2010-3-12
收藏
得分:0 
#include <stdio.h>
struct month
{int number;
char english_name;
int days;
}mon[12];
enum english_month{J,F,M,A,K,J,G,H,S,O,N,D};
enum english_month month_englishname;
int main(void)
{int i;
for(i=1;i<=12;i++)
{mon[i-1].number=i;
    char month_englishname;
month_englishname=1;
switch(month_englishname)
{
case J:mon[i-1].english_name="January";
break;
case F:mon[i-1].english_name="February";
break;
case M:mon[i-1].english_name="Marcy";
break;
case A:mon[i-1].english_name="April";
break;
case K:mon[i-1].english_name="May";
break;
case J:mon[i-1].english_name="June";
break;
case G:mon[i-1].english_name="July";
break;
case H:mon[i-1].english_name="August";
case S:mon[i-1].english_name="September";
case O:mon[i-1].english_name="October";
break;
case N:mon[i-1].english_name="November";
break;
case D:mon[i-1].english_name="December";
break;
}
month_englishname++;
if(i%2==0)
mon[i-1].days=30;
else mon[i-1].days=31;
printf("月份  英语名  天数\n");
printf("%d\t%s\t%d\n",mon[i-1].number,mon[i-1].english_name,mon[i-1].days);
}
return 0;
}
我又改了一下,可是还是有同一个错误,你再看看是怎么回事!
2010-03-17 17:56
幻or
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-2-1
收藏
得分:0 
顶下 、、、
2010-03-17 23:15
haoliliang88
Rank: 1
等 级:新手上路
帖 子:26
专家分:3
注 册:2010-3-12
收藏
得分:0 
狠人啊,顶啊,顶啊
2010-03-17 23:55
mghxz252
Rank: 2
等 级:论坛游民
帖 子:40
专家分:60
注 册:2010-1-18
收藏
得分:0 
5楼的强悍啊,
2010-03-18 08:56
快速回复:新手想问问问题出在哪了
数据加载中...
 
   



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

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