枚举 时间 判断 选择 菜单

include

include

include //调用clock_t函数

include //调用rund()函数

using namespace std;

enum Color{BLACK,WHITE,BLUE=100,RED}; //枚举:定义新变量

main()

{

clock_t start,finish;

double totaltime;

start=clock();
//时间函数

/*int j;

int i;

char ch;

cout<<"请输入学生成绩判断成绩等级。"<

loop:cin>>i;

for(j=1;j<1000;j++)

{

if(i>100 || i<0)

{

cout<<"成绩输入错误,请重新输入!"<

goto loop; // goto loop : 分号 指到达loop处

}

else if(i<=100 && i>90)

cout<<"此子为甲等!"<

else if(i<=90 && i>80)

cout<<"此子为乙等!"<

else if(i<=80 && i>70) //把你的程序代码插入到这里面

cout<<"此子为丙等!"<

else if(i<=80 && i>60)

cout<<"此子为丁等!"<

else

cout<<"此子不及格,请复读!"<

}

cout<<"程序运行1000次的时间!"<

finish=clock();

totaltime=(double)(finish-start)/CLOCKS_PER_SEC;

cout<<"\n此程序的运行时间为"<

cout<<"输入Y继续判断,输入N退出"<

cin >>ch;

if(ch == 'y'|| ch == 'Y')

goto loop;

if(ch == 'n'|| ch== 'N')

/
/

//叁 枚举 枚举类型为整形

Color cloth = WHITE;

Color hat= RED;

cout <<"Color cloth = "<< cloth << endl; //输出: color hat = 1 从零开始,依次递增

cout <<"Color hat = "<< hat << endl; //输出: color hat = 101 前一位数+1
*/

//肆 表达式

//int a,b,c,d;
//a=10,b=5; //逗号表达式
//b = (a=5)+(++a); //求值顺序 ?会由于计算机或编程软件的不同,产生 不同编译结果
//c = (a>b)? a:b ; //三元操作符
//cout<<"c = "< //cout <<"b = "< //d = (a =0,b=1,c=2,c=3); //× 最好不要这样用,复杂且不易于理解,易犯错。。
//cout <<"d = "<

/* 伍 运算
int c,d,e,f;
c = 1|2-3;
d = 1&2|3; //先加减后三目运算 & ,|, ^ 优先级依次降低
e = 1^2&-3;
f = 1|2&3;
cout<<"c = "< cout<<"d = "< cout<<"e = "< cout<<"f = "< */
//陆 程序语句 ①控制语句 ②表达式语句 ③空语句 ④语句块
//①控制语句 又叫流程控制语句 判断 循环 多路选择语句 if switch case: while goto loop
//② 表达式语句 进行表达式计算的语句 --i;也算语句 有运算符和结束符
//③空语句 只有分号,没有其他语句
//④语句块 多个语句构成语句块

/* switch 选择语句
int s;
cout<<"1--good moring"< cout<<"2--good afternoon"< cout<<"3--good evering"< cout<<"choose 1--3"< cin >>s;
switch( s)
{
case 1:
{
int s = 100;
cout< }
cout<<"1--good moring"< case 2:cout<<"2--good afternoon"< case 3:cout<<"3--good evering"< default:cout<<"choose 1--3"< }
/
/
循环语句

int total=0;
int money;
while(total<500)
{
cout<<"钱还不够500,再给点钱吧!"< cin>>money;
total+=money;
if((500-total)>0)
cout<<"还差"<<500-total<<"钱"< }
cout<<"现在有"<

/
/

int c = 0;
long t = time(NULL);
t +=5;
while(time(NULL) {
cout<<++c< }
/
/

int n = 5 ,i=1;
while(n > 0)
{
long t = time(NULL);
t +=1;
while(time(NULL) }
cout< n--;
}
/
/

int i;
do{
cout<<"显示菜单"< cout<<"1.上衣"< cout<<"2.裤子"< cout<<"3.袜子"< cout<<"4.鞋子"< cout<<"输入选择"< cin>>i;
}while(i>4|| i<1); //do while 循环 与菜单的结合,可以先读出菜单,再进行选择
switch(i)
{

case 1: cout<<"上衣颜色."< case 2: cout<<"裤子颜色"< case 3: cout<<"袜子颜色"< case 4: cout<<"鞋子颜色"< default: break;
}
*/

/
int sq,total;
for(;;) // break 仅在循环和switch 中有用。反复循环,直到输入0,退出
{
cin>>sq;
total = sq
sq;
if(total==0)
break;
cout< }
/
/
int i=1,n;
cout<<"班级有几名同学"< cin>>n;
int math[n],total=0;
for(i;i {
cout<<"输入数学成绩"< cin>>math[i];
total= math[i]+total;
cout<<"第"< }

cout< cout< */

/* 、拾
int a,b,table;
for(a=1;a<10;a++)
{
for(b=1;b<=a;b++)
cout<"<b<<" "; //九九乘法表 第二个for循环 b<=a
cout<<"\n"< }
/
/
int j=1;
for (int i = 1; i <= 9; )
{
cout< if (j >= i)
{
cout<<"\n"< j = 1;
i++; //仅使用一个for循环。
}else{
j++;
}

}
*/

/*for(int i=0;i<10;i++)
 cout<
    */

finish=clock();
totaltime=(double)(finish-start)/CLOCKS_PER_SEC;
cout<<"\n此程序的运行时间为"< return 0;

}

你可能感兴趣的:(枚举 时间 判断 选择 菜单)