#include"iostream.h"
enum day{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday};
void nextday(day &D);
void display(day D);
int main()
{
day today=Sunday;
for(int i=0;i<7;i++)
{
cout<<"Data in today="<<today<<endl;
display(today);
nextday(today);
}
return 0;
}
void nextday(day &D)
{
switch(D)
{
case Sunday:
D=Monday;
break;
case Monday:
D=Tuesday;
break;
case Tuesday:
D=Wednesday;
break;
case Wednesday:
D=Thursday;
break;
case Thursday:
D=Friday;
break;
case Friday:
D=Saturday;
break;
case Saturday:
D=Sunday;
break;
}
}
void display(day D)// 请问这里为什么要写成(day D)为什么不能写成(day &D)
{
switch(D)
{
case Sunday:
cout<<"Sunday"<<endl;
break;
case Monday:
cout<<"Monday"<<endl;
break;
case Tuesday:
cout<<"Tuesday"<<endl;
break;
case Wednesday:
cout<<"Wednesday"<<endl;
break;
case Thursday:
cout<<"Thursday"<<endl;
break;
case Friday:
cout<<"Friday"<<endl;
break;
case Saturday:
cout<<"Saturday"<<endl;
break;
}
}
慕少森
有只小跳蛙
慕慕森
相关分类