C++算法问题帮看一下

来源:百度知道 编辑:UC知道 时间:2024/06/16 10:12:00
for(int j=0;j<100;j++)
{

cin>>temp;
instr[j]=temp;
if (temp==13) break;//这里对吗?

}
输入的是回车就结束,跳出循环

right

在书写变量说明时,应注意以下几点:
1.允许在一个类型说明符后,说明多个相同类型的变量。各变量名之间用逗号间隔。类型说明符与变量名之间至少用一个空格间隔。
2.最后一个变量名之后必须以“;”号结尾。
3.变量说明必须放在变量使用之前。一般放在函数体的开头部分。
[Practice] //1int a,b;
short int c;
short d=100;
a=d-20;
b=a+d;
c=a+b+d;
d=d-a+c-b;'Vtable
a,2,0
b,2,0
c,2,0
d,2,100
of Vtable
'Vupdate
1,0;2,0
3,0
4,100
1,80
2,180
3,360
4,200
of Vupdate
of Practice
[Practice] //2int a=5;
int b=9;
long int c;
long d;
c=a+b-7;
d=a*b*c;
c=d*d*d;
a=c-d;'Vtable
a,2,5
b,2,9
c,4,0
d,4,0
of Vtable
'Vupdate
1,5
2,9
3,0
4,0
3,7
4,315
3,31255875
1,-5112
of Vupdate
of Practice
[Practice] //3int a=6,b=19;
unsigned int c;
int d;
c=a-b+7;
d=b*c;
a=b+c+d;
b=-a;'Vtable
a,2,6
b,2,19
c,2,0
d,2,0
of Vtable