读程题C语言
四、读程题,请写出以下程序的运行结果1.#include<stdio.h>main(){intx;for(x=1;x<10;x++)if(x%2==0)printf(“%...
四、 读程题,请写出以下程序的运行结果
1. #include <stdio.h>
main( )
{
int x;
for(x=1;x<10;x++)
if(x%2==0)
printf(“%d\n”, x);
}
2. #include <stdio.h>
main()
{
int x=1,y=1,z=1;
y=y+z;
x=x+y;
printf(“%d\n”, x<y?x:y);
printf(“%d\n”, x<y?x++:y++);
printf(“%d,%d\n”,x,y);
}
3. #include <stdio.h>
main()
{
int x,y,z,u;
x=6;y=5,z=7;u=x;
if(x<y) u=y; printf(“u=%d\n”,u);
if(u<z) u=z; printf(“u=%d\n”,u);
}
4. #include <stdio.h>
main( )
{
int a;
a=10;
while(a<=20){
if(a%3= =0)
printf(“%4d”, a);
a++;
}
}
5. #include <stdio.h>
main()
{
int row=6, column;
while(row>1){
column=1;
while(column<=6){
printf(“%c”, row%2?’<’:’>’);
column=column+1;
}
row=row-1;
printf(“\n”);
}
}
6. #include <stdio.h>
main( )
{
int x;
for(x=1;x<10;x++)
if(x%3==0)
printf(“%d\n”,++x);
}
7. #include <stdio.h>
void f1(void);
void f2(void);
int x=5;
main()
{
int x=5;
printf (“x=%d\n”, x);
x++;
f1();
f2();
f1();
printf (“x=%d\n”, x);
}
void f1(void)
{ static int x=5;
printf (“x=%d\n”, x);
x++;
printf (“x=%d\n”, x);
}
void f2(void)
{ printf (“x=%d\n”, x);
x--;
printf(“x=%d\n”, x);
}
8. 当从键盘输入:4321<回车>,下面程序运行结果是___________________________
#include <stdio.h>
main(){
int x, t;
scanf(“%d”, &x);
for(t=0; x!=0; x=x/10)
t=t+(x%10)*(x%10);
printf(“the value is: %d”,t);
} 展开
1. #include <stdio.h>
main( )
{
int x;
for(x=1;x<10;x++)
if(x%2==0)
printf(“%d\n”, x);
}
2. #include <stdio.h>
main()
{
int x=1,y=1,z=1;
y=y+z;
x=x+y;
printf(“%d\n”, x<y?x:y);
printf(“%d\n”, x<y?x++:y++);
printf(“%d,%d\n”,x,y);
}
3. #include <stdio.h>
main()
{
int x,y,z,u;
x=6;y=5,z=7;u=x;
if(x<y) u=y; printf(“u=%d\n”,u);
if(u<z) u=z; printf(“u=%d\n”,u);
}
4. #include <stdio.h>
main( )
{
int a;
a=10;
while(a<=20){
if(a%3= =0)
printf(“%4d”, a);
a++;
}
}
5. #include <stdio.h>
main()
{
int row=6, column;
while(row>1){
column=1;
while(column<=6){
printf(“%c”, row%2?’<’:’>’);
column=column+1;
}
row=row-1;
printf(“\n”);
}
}
6. #include <stdio.h>
main( )
{
int x;
for(x=1;x<10;x++)
if(x%3==0)
printf(“%d\n”,++x);
}
7. #include <stdio.h>
void f1(void);
void f2(void);
int x=5;
main()
{
int x=5;
printf (“x=%d\n”, x);
x++;
f1();
f2();
f1();
printf (“x=%d\n”, x);
}
void f1(void)
{ static int x=5;
printf (“x=%d\n”, x);
x++;
printf (“x=%d\n”, x);
}
void f2(void)
{ printf (“x=%d\n”, x);
x--;
printf(“x=%d\n”, x);
}
8. 当从键盘输入:4321<回车>,下面程序运行结果是___________________________
#include <stdio.h>
main(){
int x, t;
scanf(“%d”, &x);
for(t=0; x!=0; x=x/10)
t=t+(x%10)*(x%10);
printf(“the value is: %d”,t);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询