当前位置:首页 > 2014年春计算机等级二级考试C语言笔试试题
#include
void fun( int a[][4], int n) { int colmax, i, j; for( i=0;i for( j=1;j<4;j++) if(a[i][j]>a[i][colmax]) ; __(20)___; if(colmax!=0) { int t=a[i][0]; a[i][0]= __(21)___; a[i][colmax]=t ; } } } int main() { int a[4][4],i,j; for(i=0;i<4;i++) for(j=0;j<4;j++) scanf(\ fun(a,4); for(i=0;i<4;i++) { for(j=0;j<4;j++) printf(\ printf(\ } return 0; } 15. 以下程序中fun函数的功能是:将x值的的十进制表示中各位上的数字进行分解重组,从而得到一个最大数和一个最小数;用最大数减去最小数的差作为返回值。例如,当x=213465789时,对x值的各位上数字分解重组后得到最大数是987654321,最小数是123456789,因此最大数减去最小数的差值是864197532。 #include { long x=213465789,y; y=fun(x); printf(\ return 0; } long fun(long x) { long t,max,min; int i,j,k,a[10]; k=0 ; while(x>0) { a[k++]=__(24)___ ; x=x/10; } for(i=0;i for(j=0;j t=a[j], __(25)___ , a[j+1]=t; max=min=0; for(i=0; i { max=max*10+__(26)___; min=min*10+a[i]; } return max-min; } 16、链表合并。已知函数POT *merge(POT *h1, POT *h2)的形参h1指向的链表是按成员x的值升序排列的有序链表。merge函数的功能是将h2指向的链表合并到h1指向的链表中。合并完成后h1指向的链表仍是具有上述特性的有序链表。函数返回h1链表首结点的地址。 #include #include struct point *next; }POT; POT *merge( POT *h1, POT *h2) { POT *p, *p1, *p2; h2=h2->next; while(__(27)___!=NULL) { p=h2; h2=h2->next; if(h1==NULL) { h1=p; h1->next=NULL; } else if(p->x { __(28)___=h1; h1=p; } else if(h1->next==NULL) { h1->next=p; p->next=NULL; } else { p1=h1; p2=h1->next; while(p->x > p2->x &&__(29)___!=NULL) { p1=p2; p2=p2->next; } if(p->x > p2->x) { p2->next=p; p->next=NULL; } else { p->next=__(30)___; p1->next=p; } } } return h1; }
共分享92篇相关文档