现在的位置: 首页 > 14 二级C语言 > 正文

全国二级C上机真题解析

2012年12月06日 14 二级C语言 ⁄ 共 601字 ⁄ 字号 暂无评论
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include     <stdio.h>
void fun(char  *s)
{  int  i, n, k;    char c;
   n=0;
   for(i=0; s[i]!='\0'; i++)  n++;
/**********found**********/
   if(n%2==0) k=n-____ ;
   else       k=n-2;
/**********found**********/
   c=______;
   for(i=k-2; i>=1; i=i-2)  s[i+2]=s[i];
/**********found**********/
   s[1]=_________;
}
main()
{  char  s[80];
   scanf("%s", s);   
   fun(s);
   printf("%s\n",s);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
long fun (int a, int n)
{  int  j ;
/**************found**************/
   long  s = 0,  t = 1 ;
   for ( j = 0 ; j < n ; j++)
      t = t * 10 + a ;
   s = t ;
   for ( j = 1 ; j < n ; j++) {
/**************found**************/
     t = t % 10 ;
     s = s - t ;
   }
   return(s) ;
}
 
main( )
{  int  a, n ;
   scanf(  "%d%d", &a, &n ) ;
   printf( "%ld\n", fun ( a, n ) );
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <string.h>
void fun(char *tt, int pp[])
{
    int i;
    for (i=0; i<26; i++) pp[i]=0;
    for (i=0; tt[i]!='\0'; i++)
        if (islower(tt[i]))
            pp[tt[i]-'a']++;
}
 
main( )
{
    char aa[1000] ;
    int  bb[26], k ;
    scanf("%s", aa) ;
    fun(aa, bb) ;
    for (k = 0 ; k<26; k++)
        printf ("%d ", bb[k]) ;
    printf( "\n" ) ;
}
【上篇】
【下篇】

抱歉!评论已关闭.