微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
第22套题
一、程序填空题
#include <stdio.h>
int fun(int x)
{ int n, s1, s2, s3, t;
n=0;
t=100;
/**********found**********/
while(t<=__1__){
/**********found**********/
s1=t%10; s2=(__2__)%10; s3=t/100;
/**********found**********/
if(s1+s2+s3==__3__)
{ printf("%d ",t);
n++;
}
t++;
}
return n;
}
main()
{ int x=-1;
while(x<0)
{ printf("Please input(x>0): "); scanf("%d",&x); }
printf("\nThe result is: %d\n",fun(x));
}
二、程序改错题
#include <stdio.h>
/************found************/
void fun (long s, long t)
{ long sl=10;
s /= 10;
*t = s % 10;
/************found************/
while ( s < 0)
{ s = s/100;
*t = s%10*sl + *t;
sl = sl * 10;
}
}
main()
{ long s, t;
printf("\nPlease enter s:"); scanf("%ld", &s);
fun(s, &t);
printf("The result is: %ld\n", t);
}
三、程序编写题
#include <stdio.h>
#define N 16
typedef struct
{ char num[10];
int s;
} STREC;
void fun( STREC a[] )
{
}
main()
{ STREC s[N]={{"GA005",85},{"GA003",76},{"GA002",69},{"GA004",85},
{"GA001",91},{"GA007",72},{"GA008",64},{"GA006",87},
{"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91},
{"GA011",66},{"GA017",64},{"GA018",64},{"GA016",72}};
int i;FILE *out ;
fun( s );
printf("The data after sorted :\n");
for(i=0;i<N; i++)
{ if( (i)%4==0 )printf("\n");
printf("%s %4d ",s[i].num,s[i].s);
}
printf("\n");
out = fopen("K:\\k01\\24010001\\out.dat","w") ;
for(i=0;i<N; i++)
{ if( (i)%4==0 && i) fprintf(out, "\n");
fprintf(out, "%4d ",s[i].s);
}
fprintf(out,"\n");
fclose(out) ;
}