资源描述:
《CCF历年真题C语言答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、.题1:出现次数最多的数#includeintmain(){inti,j,n,s;intt=1;inta[10001]={0};scanf("%d",&n);for(i=0;ia[t])t=s;if(a[s]==a[t])t=(sintmain(){intsum=0;chara[1
2、3]={' '};gets(a);sum=(a[0]-'0')*1+(a[2]-'0')*2+(a[3]-'0')*3+(a[4]-'0')*4+(a[6]-'0')*5+(a[7]-'0')*6+(a[8]-'0')*7+(a[9]-'0')*8+(a[10]-'0')*9;if((sum%11==a[12]-'0')
3、
4、(sum%11==10&&a[12]=='X'))//注意正确情况几种类型{printf("Right");}else{if(sum%11==10)a[12]='X';elsea[12]=sum%11+'
5、0';puts(a);word资料.}return0;}题3:相反数#includeintmain(){inti,j,n,t=0;inta[501];scanf("%d",&n);for(i=0;itypedefstructwindow1{intx
6、1,x2,y1,y2,order;}window;voidInputwindow(windowws[],intn){inti;for(i=1;i<=n;i++){scanf("%d%d%d%d",&ws[n-i].x1,&ws[n-i].y1,&ws[n-i].x2,&ws[n-i].y2);ws[n-i].order=i;}}intgetpos(windowws[],intn,intx,inty){word资料.inti;for(i=0;i=ws[i].x1&&x<=ws[i].x2&&y>=ws[
7、i].y1&&y<=ws[i].y2){returni;}}return-1;}voidmovewindow(windowws[],intn,intpos){windoww=ws[pos];inti;for(i=pos-1;i>=0;i--){ws[i+1]=ws[i];}ws[0]=w;}intmain(){inti,n,m,x,y,pos;scanf("%d%d",&n,&m);windowws[n];Inputwindow(ws,n);for(i=0;i8、tpos(ws,n,x,y);if(pos==-1){printf("IGNORED");}else{printf("%d",ws[pos].order);movewindow(ws,n,pos);}}return0;}题5:相邻数对#includeword资料.#includeintmain(){inti,j,n,t=0;inta[1001];scanf("%d",&n);for(i=0;i9、or(j=i+1;jintmain(){inti,j,n,k,t=0;inta[101][4];scanf("%d",&n);for(i=0;i10、k++){if(j>=a[k][0]&&j=a[k][1]&&iintmain(){