微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
第三套:
填空:
#include <stdio.h>
void fun(char *s)
{ int i, j=0, k=0; char t1[80], t2[80];
for(i=0; s[i]!='\0'; i++)
if(s[i]>='0' && s[i]<='9')
{
/**********found**********/
t2[j]=s[i]; ___1___;
}
else t1[k++]=s[i];
t2[j]=0; t1[k]=0;
/**********found**********/
for(i=0; i<k; i++) ___2___;
/**********found**********/
for(i=0; i<___3___; i++) s[k+i]=t2[i];
}
main()
{ char s[80]="ba3a54j7sd567sdffs";
printf("\nThe original string is : %s\n",s);
fun(s);
printf("\nThe result is : %s\n",s);
}
改错:
#include <stdio.h>
#include <string.h>
#define MAXLINE 20
fun ( char *pstr[6])
{ int i, j ;
char *p ;
for (i = 0 ; i < 5 ; i++ ) {
/**************found**************/
for (j = i + 1, j < 6, j++)
{
if(strcmp(*(pstr + i), *(pstr + j)) > 0)
{
p = *(pstr + i) ;
/**************found**************/
*(pstr + i) = pstr + j ;
*(pstr + j) = p ;
}
}
}
}
main( )
{ int i ;
char *pstr[6], str[6][MAXLINE] ;
for(i = 0; i < 6 ; i++) pstr[i] = str[i] ;
printf( "\nEnter 6 string(1 string at each line): \n" ) ;
for(i = 0 ; i < 6 ; i++) scanf("%s", pstr[i]) ;
fun(pstr) ;
printf("The strings after sorting:\n") ;
for(i = 0 ; i < 6 ; i++) printf("%s\n", pstr[i]) ;
}
编程:
#include <stdio.h>
#include <string.h>
#define M 81
int fun(char *ss, char c)
{
}
main()
{ char a[M], ch;
void NONO ( );
printf("\nPlease enter a string:"); gets(a);
printf("\nPlease enter a char:"); ch = getchar();
printf("\nThe number of the char is: %d\n", fun(a, ch));
NONO ( );
}
第三套:
填空:
1、j++ 2、s[i]=t1[i] 3、j
改错:
1、for (j = i + 1, j < 6, j++) 改为for(j=i+1;j<6;j+=1))
2、*(pstr + i) = pstr + j ;改为*(pstr+i)=*(pstr+j);
编程:
int fun(char *ss, char c)
{
int n=0,i=0;
while(ss[i])
{
if(ss[i]==c)
{
n++;
}
i++;
}
return n;
}
第四套:
填空:
#include <stdio.h>
#define N 4
/**********found**********/
void fun(int (*t)___1___ )
{ int i, j;
for(i=1; i<N; i++)
{ for(j=0; j<i; j++)
{
/**********found**********/
___2___ =t[i][j]+t[j][i];
/**********found**********/
___3___ =0;
}
}
}
main()
{ int t[][N]={21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10}, i, j;
printf("\nThe original array:\n");
for(i=0; i<N; i++)
{ for(j=0; j<N; j++) printf("%2d ",t[i][j]);
printf("\n");
}
fun(t);
printf("\nThe result is:\n");
for(i=0; i<N; i++)
{ for(j=0; j<N; j++) printf("%2d ",t[i][j]);
printf("\n");
}
}
改错:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/************found************/
#define FU(m,n) (m/n)
float fun(float a,float b,float c)
{ float value;
value=FU(a+b,a-b)+FU(c+b,c-b);
/************found************/
Return(Value);
}
main()
{ float x,y,z,sum;
printf("Input x y z: ");
scanf("%f%f%f",&x,&y,&z);
printf("x=%f,y=%f,z=%f\n",x,y,z);
if (x==y||y==z){printf("Data error!\n");exit(0);}
sum=fun(x,y,z);
printf("The result is : %5.2f\n",sum);
}
编程:
#include <stdio.h>
void fun( char *a )
{
}
main()
{ char s[81];
void NONO ( );
printf("Enter a string:\n");gets(s);
fun( s );
printf("The string after deleted:\n");puts(s);
NONO();
}