当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
综合指导:计算机二级笔试试题三(10)
发布时间:2010/10/20 16:58:19 来源:www.xue.net 编辑:城市总裁吧

    12) 下面程序的功能是:将字符数组a中下标值为偶数的元素从小到大排列,其它元素不变。请填空。

    #include <stdio.h>

    #include <string.h>

    main()

    { char a[]="clanguage",t;

    int i, j, k;

    k=strlen(a);

    for(i=0; i<=k-2; i+=2)

    for(j=i+2; j<=k; [15] )

    ------

    if( [16] )

    ------

    { t=a[i]; a[i]=a[j]; a[j]=t; }

    puts(a);

    printf("\n");

    }

    (13) 以下程序的运行结果是 [17]

    ------

    #include <stdio.h>

    main()

    { int k=4, m=1, p;

    p=func(k,m); printf("%d,",p);

    p=func(k,m); printf("%d \n",p);

    }

    func(int a, int b)

    { static int m=0, i=2;

    i+=m+1;

    m=i+a+b;

    return m;

    }

    (14) 以下程序的功能是:将无符号八进制数字构成的字符串转换为十进制整数。例如,输入的字符串为:556,则输出十进制整数366。请填空。

    #include <stdio.h>

    main()

    { char *p, s[6];

    int n;

    p=s;

    gets(p);

    n=*p-'0';

    while( [18] !='\0')n=n*8+*p-'0';

    ------

    printf("%d \n",n);

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved