Ìî¿ÕÌ⣨CÓïÑÔ£© ÏÂÔØ±¾ÎÄ

Ìî¿ÕÌâ(C) 13

»ØÖ÷º¯Êý¡£ÀýÈ磬µ±n=123114350ʱ£¬½á¹ûÓ¦¸ÃΪ£»c1=3 c1='W'; c2 = fun(c1);

c2=1 c3=2¡£ #include int c1,c2,c3; void fun(long n) { c1 = c2 = c3 = 0; while (n) {

/**********found**********/ switch(___1___) {

/**********found**********/ case 1: c1++;___2___; /**********found**********/

case 2: c2++;___3___; case 3: c3++; } n /= 10; } }

main()

{ long n=123114350L; fun(n);

printf(\

printf(\}

´ð°¸£º¡¾1¡¿n ¡¾2¡¿break ¡¾3¡¿break 36£®º¯ÊýfunµÄ¹¦ÄÜÊǽøÐÐ×Öĸת»»¡£ÈôÐβÎchÖÐÊÇСдӢÎÄ×Öĸ£¬Ôòת»»³É¶ÔÓ¦µÄ´óдӢÎÄ×Öĸ£¬ÈôchÖÐÊÇ´óдӢÎÄ×Öĸ£¬Ôòת»»³É¶ÔÓ¦µÄСдӢÎÄ×Öĸ£»ÈôÊÇÆäËü×Ö·ûÔò±£³Ö²»±ä£»²¢½«×ª»»ºóµÄ½á¹û×÷Ϊº¯ÊýÖµ·µ»Ø¡£ #include #include char fun(char ch) {

/**********found**********/

if ((ch>='a')___1___(ch<='z')) return ch -'a' + 'A'; if ( isupper(ch) )

/**********found**********/

return ch +'a'-___2___ ; /**********found**********/ return ___3___; }

main()

{ char c1, c2;

printf(\ c1='w'; c2 = fun(c1);

printf(\

printf(\ c1='8'; c2 = fun(c1);

printf(\}

´ð°¸£º¡¾1¡¿&& ¡¾2¡¿'A' ¡¾3¡¿ch

37£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǶÔÖ¸¶¨×Ö·ûÔÚ×Ö·û´®aÖгöÏֵĴÎÊý½øÐÐͳ¼Æ£¬Í³¼ÆµÄÊý¾Ý´æµ½bÊý×éÖС£ÆäÖУº×Ö·û¡®z¡¯³öÏֵĴÎÊý´æ·Åµ½b[0]ÖУ¬×Ö·û¡®Y¡¯³öÏֵĴÎÊý´æ·Åµ½b[1]ÖУ¬×Ö·û¡®X¡¯³öÏֵĴÎÊý´æ·Åµ½b[2]ÖУ¬×Ö·û¡®W¡¯³öÏֵĴÎÊý´æ·Åµ½b[3]ÖУ¬×Ö·û¡®V¡¯³öÏֵĴÎÊý´æ·Åµ½b[4]ÖУ¬ÆäËü×Ö·û³öÏֵĴÎÊý´æ·Åµ½b[5]ÖС£ÀýÈ磬µ±aÖеÄ×Ö·û´®Îª¡°AYYZXW1Y+ZWVP¡±£¬µ÷Óøú¯Êýºó£¬bÖдæ·ÅÊý¾ÝÓ¦ÊÇ£º2¡¢3¡¢1¡¢2¡¢l¡¢4¡£ #include #include void fun(char *a, int b[]) {

int i;

for (i=0; i<6; i++) b[i] = 0; /**************found**************/ for (i=0; i< ___1___(a); i++)

if (a[i] >= 'V' && a[i] <= 'Z') b[4-(a[i]-'V')]++; /**************found**************/ ___2___ b[5]++; }

main()

{ int i, b[6]; char a[100] = \/**************found**************/ fun(___3___);

printf(\

for (i=0; i<6; i++) printf(\ printf(\

}

´ð°¸£º¡¾1¡¿strlen ¡¾2¡¿else ¡¾3¡¿a,b

38£®º¯ÊýfunµÄ¹¦ÄÜÊÇ£º½«ÐβÎaËùÖ¸Êý×éÖеÄǰ°ë²¿·ÖÔªËØÖеÄÖµºÍºó°ë²¿·ÖÔªËØÖеÄÖµ¶Ô»»¡£ÐβÎnÖдæ·ÅÊý×éÖÐÊý¾ÝµÄ¸öÊý£¬ÈônÎªÆæÊý£¬ÔòÖмäµÄÔªËØ²»¶¯¡£ÀýÈ磺ÈôaËùÖ¸Êý×éÖеÄÊý¾ÝÒÀ´ÎΪ£º1¡¢2¡¢3¡¢4¡¢5¡¢6¡¢7¡¢8¡¢9£¬Ôòµ÷»»ºóΪ£º6¡¢7¡¢8¡¢9¡¢5£¬1¡¢2¡¢3¡¢4¡£ #include #define N 9

void fun(int a[], int n) { int i, t, p;

/**********found**********/

p = (n%2==0)?n/2:n/2+___1___; for (i=0; i

Ìî¿ÕÌâ(C) 14

{

t=a[i];

/**********found**********/ a[i] = a[p+___2___]; /**********found**********/ ___3___ = t; } }

main()

{ int b[N]={1,2,3,4,5,6,7,8,9}, i; printf(\ for (i=0; i

printf(\ for (i=0; i

}

´ð°¸£º¡¾1¡¿1 ¡¾2¡¿i ¡¾3¡¿a[p+i] 39£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǰÑs´®ÖÐËùÓеÄ×Ö·ûÇ°ÒÆÒ»¸öλÖ㬴®ÖеĵÚÒ»¸ö×Ö·ûÒÆµ½×îºó¡£ÀýÈ磺s´®ÖÐÔ­ÓеÄ×Ö·û´®Îª£ºMn£®123xyZ£¬Ôòµ÷Óøú¯Êýºó£¬s´®ÖеÄÄÚÈÝΪ£ºn£®123xyZM¡£

#include #define N 81 fun ( char *s ) {

char b[N] ;

sprintf(b, \/**************found**************/ strcpy(___1___) ; }

main( )

{ char a[ N ] ;

printf ( \ printf ( \original string is : \); puts( a ); /**************found**************/ fun ( ___2___ );

printf ( \/**************found**************/ ___3___ ( a );

}

´ð°¸£º¡¾1¡¿s, b ¡¾2¡¿a ¡¾3¡¿puts

40£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǼÆËã²¢Êä³öhighÒÔÄÚ×î´óµÄ10¸öËØÊýÖ®ºÍ¡£highº¯ÊýÓÉÖ÷º¯Êý´«¸øfunº¯Êý¡£ÈôhighµÄֵΪ100£¬Ôòº¯ÊýµÄֵΪ732¡£ #include

#include

int fun( int high )

{ int sum = 0, n=0, j, yes;

/************found************/

while ((high >= 2) ___1___ (n < 10)) {

yes = 1;

for (j=2; j<=high/2; j++ ) if (high % j ==0 ){

/************found************/ yes=0; ___2___;

}

if (yes) { sum +=high; n++; } /************found************/ ___3___; }

return sum ; }

main ( ) {

printf(\}

´ð°¸£º¡¾1¡¿&& ¡¾2¡¿break ¡¾3¡¿high--

41£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊÇɾ³ýwÊý×éÖÐϱêΪkµÄÔªËØÖеÄÖµ¡£³ÌÐòÖУ¬µ÷ÓÃÁËgetindex¡¢arroutºÍarrdelÈý¸öº¯Êý£¬getindexÓÃÒÔÊäÈëËùÉ¾ÔªËØµÄϱ꣬º¯ÊýÖжÔÊäÈëµÄÏÂ±ê½øÐмì²é£¬ÈôÔ½½ç£¬ÔòÒªÇóÖØÐÂÊäÈ룬ֱµ½ÕýȷΪֹ¡£arroutÓÃÒÔÊä³öÊý×éÖеÄÊý¾Ý£¬arrdel½øÐÐËùÒªÇóµÄɾ³ý²Ù×÷¡£

#include #define NUM 10

arrout ( int *w, int m ) { int k;

/************found************/ for (k = 0; k < ___1___; k++) printf (\ printf (\}

arrdel ( int *w, int n, int k )

{ int i;

for ( i = k; i < n-1; i++ ) w[i] = w[i+1]; n--;

/************found************/ return ___2___; }

Ìî¿ÕÌâ(C) 15

getindex( int n )

{ int i;

/************found************/

___3___

{ printf(\the index [ 0<= i< %d ]: \n ); scanf (\

} while( i < 0 || i > n-1 ); return i; } main( )

{ int n, d, a[NUM]={21,22,23,24,25,26,27,28,29,30}; n = NUM;

printf (\ d = getindex( n ); n = arrdel ( a, n, d ); printf (\the data after delete :\\n\

arrout( a, n );

}

´ð°¸£º¡¾1¡¿m ¡¾2¡¿n ¡¾3¡¿do

42.¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊÇ´Ó×Ö·û´®sβ²¿¿ªÊ¼£¬°´ÄæÐò°ÑÔÚÆäÖгöÏÖµÄÿÏàÁÚµÄÁ½¸ö×Ö·û£¬½ôËæÆäºóÖØ¸´³öÏÖÒ»´Î£¬·ÅÔÚÒ»¸öд®tÖУ¬Èô×Ö·û´®sÖÐÍ·²¿ÓÐÊ£ÓàµÄµ¥¸ö×Ö·ûÒ²ÖØ¸´£¬·ÅÔÚtµÄ×îºó¡£ÀýÈ磺µ±sÖеÄ×Ö·û´®Îª£»¡°12345¡±Ê±£¬ÔòtÖеÄ×Ö·û´®Ó¦Îª£»¡°5454323211¡±¡£ #include #include

void fun (char *s, char *t) { int i, j, sl; sl = strlen(s);

for(i=sl-1,j=0;i>=0;i-=2) { t[j++] = s[i];

if (i-1 >= 0) t[j++] = s[i-1]; /************found************/ t[j++] = ___1___; /************found************/ if (i-1 ___2___ 0) t[j++]=s[i-1]; }

t[j] = '\\0'; }

main()

{ char s[100], t[100];

printf(\/************found************/ fun(___3___);

printf(\}

´ð°¸£º¡¾1¡¿s[i] ¡¾2¡¿>= ¡¾3¡¿s,t

43£®¸ø¶¨³ÌÐòBLANKl.CÊǽ¨Á¢Ò»¸ö´øÍ·½áµãµÄµ¥ÏòÁ´±í£¬²¢ÓÃËæ»úº¯ÊýΪ¸÷½áµã¸³Öµ¡£º¯ÊýfunµÄ¹¦ÄÜÊǽ«µ¥ÏòÁ´±í½áµã(²»°üÀ¨Í·½áµã)Êý¾ÝÓòΪżÊýµÄÖµÀÛ¼ÓÆðÀ´£¬²¢ÇÒ×÷Ϊº¯ÊýÖµ·µ»Ø¡£ #include #include

typedef struct aa

{ int data; struct aa *next; }NODE; int fun(NODE *h)

{ int sum = 0 ;

/***********found**********/ ___1___ *p;

/***********found**********/ p=___2___;

while(p)

{ if(p->data%2==0) sum +=p->data;

/***********found**********/ p=___3___; }

return sum; }

NODE *creatlink(int n) { NODE *h, *p, *s, *q;

int i, x;

h=p=(NODE *)malloc(sizeof(NODE)); for(i=1; i<=n; i++)

{ s=(NODE *)malloc(sizeof(NODE)); s->data=rand(); s->next=p->next; p->next=s; p=p->next; }

p->next=NULL; return h; }

outlink(NODE *h, FILE *pf) { NODE *p;

p = h->next;

fprintf(pf ,\ while(p)

{ fprintf(pf ,\ fprintf (pf,\}

outresult(int s, FILE *pf)

Ìî¿ÕÌâ(C) 16

{ fprintf(pf,\main()

{ NODE *head; int even; head=creatlink(12); head->data=9000;

outlink(head , stdout);

even=fun(head);

printf(\}

´ð°¸£º¡¾1¡¿NODE ¡¾2¡¿h->next ¡¾3¡¿p->next

44£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǰÑÔÚ×Ö·û´®sÖгöÏÖµÄÿ¸ö×Ö·û£¬½ôËæÆäºóÖØ¸´³öÏÖÒ»´Î£¬ÐγÉÒ»¸öд®·ÅÔÚtÖУ¬ÇÒÔÚtÖаÑÔ­ÏàÁÚ×Ö·ûµÄλÖýøÐÐÁ˽»»»¡£ÀýÈ磻µ±sÖеÄ×Ö·û´®Îª£º¡°12345¡±Ê±£¬ÔòtÖеÄ×Ö·û´®Ó¦Îª£º¡°2211443355¡±¡£#include #include

void fun (char *s, char *t) {

int i,j,sl;

/************found************/ sl = ___1___(s);

for (i=0, j=0; i

{ t[2*j] = s[i+1]; t[2*j +1] = s[i+1]; j++; }

t[2*j] = s[i]; t[2*j +1] = s[i]; /************found************/ ___2___; }

t[2*sl] = '\\0'; }

main()

{ char s[100], t[100];

printf(\/************found************/ fun(___3___);

printf(\}

´ð°¸£º¡¾1¡¿strlen ¡¾2¡¿j++ ¡¾3¡¿s, t

45£®¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǸù¾Ý¹«Ê½ÇóPµÄÖµ£¬½á¹ûÓɺ¯ÊýÖµ´ø»Ø¡£mÓënΪÁ½¸öÕûÊýÇÒÒªÇóm>n¡£ P?m!n!(m?n)!

ÀýÈ磺m=11£¬n=4ʱ£¬ÔËÐнá¹ûΪ330.000000¡£ #include long jc(int m)

{

long s=1;

int i ;

/**************found**************/ for(i=1;i<=m;i++) s=___1___ ; return s; }

float fun(int m, int n) {

float p;

/**************found**************/ p=1.0*jc(m)/jc(n)/jc(___2___) ; /**************found**************/ ___3___; }

main() {

printf(\}

´ð°¸£º¡¾1¡¿s*i ¡¾2¡¿m-n ¡¾3¡¿return p

46.¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǰÑaÊý×éÖеÄn¸öÊý£¬ºÍbÊý×éÖÐÄæÐòµÄn¸öÊýÒ»Ò»¶ÔÓ¦Ïà³Ë¡¢Ç󯽷½£¬½á¹û´æÔÚcÊý×éÖС£ ÀýÈ磺µ±aÊý×éÖеÄÖµÊÇ£º1£¬3¡¢5¡¢7¡¢8£¬bÊý×éÖеÄÖµÊÇ£º2¡¢3¡¢4¡¢5¡¢8£¬µ÷Óøú¯Êýºó£¬cÖдæ·ÅµÄÊý¾ÝÊÇ£º64¡¢225¡¢400¡¢441¡¢256

#include

void fun(int a[], int b[], int c[], int n) {

int i;

for (i=0; i

/**************found**************/

___1___ = (a[i] * b[n-1-i]) *(a[i] * b[n-1-i]); }

main()

{ int i, a[100]={1,3,5,7,8}, b[100]={2,3,4,5,8}, c[100]; /**************found**************/ fun(___2___, 5);

printf(\

/**************found**************/

for (i=0; i<5; i++) printf(\ printf(\}

´ð°¸£º¡¾1¡¿c[i] ¡¾2¡¿a, b, c ¡¾3¡¿c[i]

47.¸ø¶¨³ÌÐòµÄ¹¦ÄÜÊǶÔÖ¸¶¨×Ö·ûÔÚ×Ö·û´®aÖгöÏֵĴÎÊý½øÐÐͳ¼Æ£¬Í³¼ÆµÄÊý¾Ý´æµ½bÊý×éÖС£ÆäÖУº×Ö·û¡®z¡¯