理论上我个人觉得很正确,可就是编译不过,郁闷,请高手们看看,谢了!!!
用枚举,用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();}