内容发布更新时间 : 2024/12/23 23:59:34星期一 下面是文章的全部内容请认真阅读。
}
for(i=0;i<=2;i++)
{for(j=0;j<=1;j++)
printf(\ } }
运行结果为:
1 4 2 5 3 6
12.
#include
for (i=0;i<=n;i++)
r=r*b[i]; return (r); }
main()
{int x,a[]={1,2,3,4,5,6,7,8,9}; x=f(a,3);
printf(“%d\\n”,x); }
运行结果为: 24 13.
#include\main() {int j,k;
static int x[4][4],y[4][4]; for(j=0;j<4;j++) for(k=j;k<4;k++) x[j][k]=j+k; for(j=0;j<4;j++) for(k=j;k<4;k++) y[k][j]=x[j][k];
for(j=0;j<4;j++) for(k=0;k<4;k++)
printf(\}
运行结果为:
0,0,0,0,1,2,0,0,2,3,4,0,3,4,5,6
函数
1.
#include
{int x, y, result = 0; scanf(\ result = Sub(x,y ) ;
printf(\}
当从键盘输入:6,3运行结果为: result =3 2.
#include
int min( int x, int y ) { int m;
if ( x> y ) m = x; else m = y; return(m); }
main() {
int a=3,b=5,abmin ; abmin = min(a,b); printf(“min is %d”, abmin); }
运行结果为: min is 5
3.
#include
printf(“%d, ”,x); }
main( )
{ int x=20; func(x);
printf(“%d”, x); }
运行结果为: 10, 20
4.
#include
int func(int x,int y) { int m=1;
return(x*y-m); }
main()
{int a=2,b=3;
printf(\
printf(\ }
运行结果为: 4 1 5.
#include
main()
{ int x=15, y=8, r; r= fun(x,y);
printf(\}
运行结果为:r=15 6.
#include
for(i=1;i<=n;i++)
f=f * i; return(f); }
main() { int j,s;
scanf(“%d”,&j); s=fac(j);
printf(\}
如果从键盘输入3, 运行结果为:3!=6
7.
#include
unsigned fun6(unsigned num) { unsigned k=1;
do
{ k*=num; num/=10; }while(num); return k; }
main()
{ unsigned n=26;
printf(“%d\\n”,fun6(n)); }
运行结果为:12 8.
#include
printf(\}
max(int x, int y) { int z;
z=x>y? x : y; return(z) ; }
运行结果为: Max is 8
指针
1.
# include < stdio .h > main ( )
{ int x[ ] = {10, 20, 30, 40, 50 }; int *p ; p=x;
printf ( “%d”, *(p+2 ) ); } 运行结果为: 30 2.
#include
{ char s[]=”abcdefg”; char *p; p=s;
printf(“ch=%c\\n”,*(p+5)); }
运行结果为: ch=f 3.
#include
{ int a[]={1, 2, 3, 4, 5} ; int x, y, *p; p=a;
x=*(p+2);
printf(\:%d \\n\; }
运行结果为: 1:3 4.
#include
{ int arr[ ]={30,25,20,15,10,5}, p++;
printf(“%d\\n”,*(p+3)); }
运行结果为:10
*p=arr;