#include<stdio.h>voidfun(int *s, int m, int n){ int t; while(m<n) {t=s[m]; s[m]=s[n]; s[n]=t; m++; n--;}}main(){ int a[5]={1,2,3,4,5},k;fun(a,0,4);for(k=0;k<5;k++) printf("%d ",a[k]);}
举一反三
- #include<stdio.h>voidfun(int s[], intm, int n){ intt; while(m<n) {t=s[m]; s[m]=s[n]; s[n]=t; m++; n--;}}main(){ Int a[5]={1,2,3,4,5},k;fun(a,0,4);for(k=0;k<5;k++) printf("%d ",a[k]);} 上面程序输出结果是
- 【填空题】#include<stdio.h> voidfun(int *s, intm, int n) { intt; while(m<n) {t=s[m]; s[m]=s[n]; s[n]=t; m++; n--;} } main() { Inta[5]={1,2,3,4,5},k; fun(a,0,4); for(k=0;k<5;k++) printf("%d ",a[k]); } 以上程序的输出结果是()
- main() { int k,P; int s[]={1,-9,7,2,-10,3}; for(p=0,k=P;p<6;p++) if(s>s[k])k=p; printf("%d\n",k); } 程序运行结果是:______
- 功能:将一个数组中的元素按逆序存放。请在空的位置填上合适的内容。#include <stdio.h>#define N 7main ( ){int a[N]={12,9,8,7,5,2,1},m,t;printf("\n the origanal array:\n");for (m=0;m<N;m++)printf("%4d",a[m]);for (m=0;m<N/2;____ ) //(2分){t=a[m];____ ; //(2分)____ ; //(2分)}printf("\n the changed array:\n");for (m=0;m<N;m++)printf("%4d",a[m]);}
- 以下程序运行的输出结果是______。 #include<stdio.h> #define M 100 void fun(int m,int *a,int *n) int i,j=0; for(i=1;j<=m;i++) if(i%7==0 ‖ i%11==0) a[j++]=i; *n=j; main( ) int aa[M],n,k; fun(10,aa,&n); for(k=0;k<n;k++) if((k+1)%20==0)printf("\n"); else printf("%4d",aa[k]); printf("\n");