| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 765 人关注过本帖
标题:理论上我个人觉得很正确,可就是编译不过,郁闷,请高手们看看,谢了!!!
只看楼主 加入收藏
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
结帖率:63.64%
收藏
已结贴  问题点数:20 回复次数:8 
理论上我个人觉得很正确,可就是编译不过,郁闷,请高手们看看,谢了!!!

用枚举,用7个数字带起星期一到星期日,再用名字输出。

程序如下:


#include"stdio.h"
#include"iostream.h"
#include"stdle.h"
enum  date name {monday,tuesday,wednesday,thursday,firdag,sutaday,sunday}
void main ()
{date name idname[10];
int i;
cout<<"0 monday,1 tuesday,2 wednesday,3 tuesday,4 firday,5 sutaday,6 sunday"<<endl;
cout<<"请输入要代替的7个数字:"<<endl;
for(i=0;i<7;i++)
{
cin>>i;
if((i<0)||(i>=7))
cout<<"输入的数字不在规定的范围内,请重输入!"<<endl;
exle(0);
else
switch(i)
{case 0: idname[i]=monday;break;
case 1: idname[i]=tuesday;break;
case 2: idname[i]=wednesday;break;
case 3: idname[i]=thursday;break;
case 4: idname[i]=firday;break;
case 5: idname[i]=sutaday;break;
case 6: idname[i]=sunday;break;}
}
for(i=0;i<7;i++)
{switch(idname[i])
{
    idname[0]:cout<<"星期一";break;
idname[1]:cout<<"星期二";break;
idname[2]:cout<<"星期三";break;
idname[3]:cout<<"星期四";break;
idname[4]:cout<<"星期五";break;
idname[5]:cout<<"星期六";break;
idname[6]:cout<<"星期日";break;}
getchar();}
搜索更多相关主题的帖子: 理论 编译 
2010-05-19 09:07
lijm1989
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:珠海
等 级:贵宾
威 望:12
帖 子:675
专家分:2844
注 册:2009-10-14
收藏
得分:2 
不觉得错误很多?
2010-05-19 10:10
yc2575757
Rank: 7Rank: 7Rank: 7
来 自:北京
等 级:黑侠
威 望:1
帖 子:113
专家分:522
注 册:2010-5-7
收藏
得分:8 
#include"stdio.h"
#include"iostream.h"
#include"stdlib.h"
enum  date_name {monday,tuesday,wednesday,thursday,friday,sutaday,sunday};
void main ()
{date_name idname[10];
int i;
cout<<"0 monday,1 tuesday,2 wednesday,3 tuesday,4 firday,5 sutaday,6 sunday"<<endl;
cout<<"请输入要代替的7个数字:"<<endl;
for(i=0;i<7;i++)
{
cin>>i;
if((i<0)||(i>=7))
{
cout<<"输入的数字不在规定的范围内,请重输入!"<<endl;
exit(0);
}
else
switch(i)
{case 0: idname[i]=monday;break;
case 1: idname[i]=tuesday;break;
case 2: idname[i]=wednesday;break;
case 3: idname[i]=thursday;break;
case 4: idname[i]=friday;break;
case 5: idname[i]=sutaday;break;
case 6: idname[i]=sunday;break;}
}
for(i=0;i<7;i++)
{switch(i)
{
   case 0:cout<<"星期一"<<endl;break;
case 1:cout<<"星期二"<<endl;break;
case 2:cout<<"星期三"<<endl;break;
case 3:cout<<"星期四"<<endl;break;
case 4:cout<<"星期五"<<endl;break;
case 5:cout<<"星期六"<<endl;break;
case 6:cout<<"星期日"<<endl;break;}
}
}
2010-05-19 10:17
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
收藏
得分:0 
回复 楼主 fanfan320
可输入6 5 4 3 2 1 0,出来的还是星期一………………星期日啊  
2010-05-19 11:01
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
收藏
得分:0 
回复 2楼 lijm1989
可输入6 5 4 3 2 1 0,出来的还是星期一………………星期日啊    ?????
2010-05-19 11:02
ybjx1987
Rank: 3Rank: 3
来 自:武汉
等 级:论坛游侠
帖 子:26
专家分:175
注 册:2008-11-26
收藏
得分:10 
#include"stdio.h"
#include"iostream.h"
#include"stdlib.h"
enum  date_name {monday,tuesday,wednesday,thursday,friday,sutaday,sunday};
void main ()
{
    date_name idname[10];
    int i,a;
    cout<<"0 monday,1 tuesday,2 wednesday,3 tuesday,4 firday,5 sutaday,6 sunday"<<endl;
    cout<<"请输入要代替的7个数字:"<<endl;
    for(i=0;i<7;i++)
    {
        cin>>a;
        if((a<0)||(a>=7))
        {
            cout<<"输入的数字不在规定的范围内,请重输入!"<<endl;
            exit(0);
        }
        else
            switch(a)
            {
                case 0: idname[i]=monday;break;
                case 1: idname[i]=tuesday;break;
                case 2: idname[i]=wednesday;break;
                case 3: idname[i]=thursday;break;
                case 4: idname[i]=friday;break;
                case 5: idname[i]=sutaday;break;
                case 6: idname[i]=sunday;break;
            }
    }
    for(i=0;i<7;i++)
    {
        switch(idname[i])
        {
            case monday:cout<<"星期一"<<endl;break;
            case tuesday:cout<<"星期二"<<endl;break;
            case wednesday:cout<<"星期三"<<endl;break;
            case thursday:cout<<"星期四"<<endl;break;
            case friday:cout<<"星期五"<<endl;break;
            case sutaday:cout<<"星期六"<<endl;break;
            case sunday:cout<<"星期日"<<endl;break;
        }
    }

}
调试成功
2010-05-19 13:53
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
收藏
得分:0 
回复 2楼 lijm1989
嘿嘿,在你的基础上该对了,呵呵,谢谢啊!!!!

#include"stdio.h"
#include"iostream.h"
#include"stdlib.h"
enum  date_name {monday,tuesday,wednesday,thursday,friday,sutaday,sunday};
void main ()
{date_name idname[10];
int i,num;
cout<<"0 monday,1 tuesday,2 wednesday,3 tuesday,4 firday,5 sutaday,6 sunday"<<endl;
cout<<"请输入要代替的7个数字:"<<endl;
for(i=0;i<7;i++)
{
cin>>num;
if((i<0)||(i>=7))
{
cout<<"输入的数字不在规定的范围内,请重输入!"<<endl;
exit(0);
}
else
switch(num)
{case 0: idname[i]=monday;break;
case 1: idname[i]=tuesday;break;
case 2: idname[i]=wednesday;break;
case 3: idname[i]=thursday;break;
case 4: idname[i]=friday;break;
case 5: idname[i]=sutaday;break;
case 6: idname[i]=sunday;break;}
}
for(i=0;i<7;i++)
{switch(idname[i])
{
  case monday:cout<<"星期一"<<endl;break;
case tuesday:cout<<"星期二"<<endl;break;
case wednesday:cout<<"星期三"<<endl;break;
case thursday:cout<<"星期四"<<endl;break;
case friday:cout<<"星期五"<<endl;break;
case sutaday:cout<<"星期六"<<endl;break;
case sunday:cout<<"星期日"<<endl;break;}
}
}
2010-05-19 15:04
fanfan320
Rank: 3Rank: 3
来 自:运城
等 级:论坛游侠
帖 子:82
专家分:104
注 册:2010-5-12
收藏
得分:0 
回复 3楼 yc2575757
呵呵,在你的基础上该对了,谢谢
#include"stdio.h"
#include"iostream.h"
#include"stdlib.h"
enum  date_name {monday,tuesday,wednesday,thursday,friday,sutaday,sunday};
void main ()
{date_name idname[10];
int i,num;
cout<<"0 monday,1 tuesday,2 wednesday,3 tuesday,4 firday,5 sutaday,6 sunday"<<endl;
cout<<"请输入要代替的7个数字:"<<endl;
for(i=0;i<7;i++)
{
cin>>num;
if((i<0)||(i>=7))
{
cout<<"输入的数字不在规定的范围内,请重输入!"<<endl;
exit(0);
}
else
switch(num)
{case 0: idname[i]=monday;break;
case 1: idname[i]=tuesday;break;
case 2: idname[i]=wednesday;break;
case 3: idname[i]=thursday;break;
case 4: idname[i]=friday;break;
case 5: idname[i]=sutaday;break;
case 6: idname[i]=sunday;break;}
}
for(i=0;i<7;i++)
{switch(idname[i])
{
  case monday:cout<<"星期一"<<endl;break;
case tuesday:cout<<"星期二"<<endl;break;
case wednesday:cout<<"星期三"<<endl;break;
case thursday:cout<<"星期四"<<endl;break;
case friday:cout<<"星期五"<<endl;break;
case sutaday:cout<<"星期六"<<endl;break;
case sunday:cout<<"星期日"<<endl;break;}
}
}
2010-05-19 15:06
tandechun
Rank: 2
来 自:广西-南宁
等 级:论坛游民
帖 子:58
专家分:35
注 册:2010-3-14
收藏
得分:0 
研究下
2010-05-19 21:48
快速回复:理论上我个人觉得很正确,可就是编译不过,郁闷,请高手们看看,谢了! ...
数据加载中...
 
   



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

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