最新福建省计算机等级考试二级C语言考试题库

时间:2025-02-23

最新福建省计算机等级考试二级C语言考试题库

改错题

#include <stdio.h>

#include <string.h>

void main()

{

char s1[100], s2[100];

int i,s_len;

printf("Please input string: \n");

gets(s1);

s_len = /**/ s1 /**/;

for(i=0; i<s_len; i++)

{

if(s1[i] >= '0' && s1[i] <= '7')

s2[i] = s1[i] + 2;

else if(s1[i] == '8'/**/ && /**/s1[i]=='9')

s2[i] = s1[i]-8;

else

s2[i] = s1[i];

}

/**/ s2[i+1] /**/ = '\0';

puts(s2);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

#include <math.h>

int prime( int x )

{

int i, mark=1 ; double k; /**/ i=1 /**/; k=(int)sqrt((double)x);

while (i<=k)

{ if(x%i==0)

{/**/ i=k+1; /**/

break;

} i++;

}

return (mark);

}

void main()

{

int a;

printf("Input a number: ");

scanf("%d",&a);

if(/**/ !prime(a) /**/)

printf("%d is a prime number.\n", a);

else

printf("It's not.\n");

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

float fun(float a)

{ return (a*a+2*a+1)/(a-1);

}

void main()

{

float x,y,z;

float result;

printf("\nPlease input x,y,z: ");

scanf(/**/ "%d%d%d" /**/,&x,&y,&z);

if(x==1 || y==1 || z==1)

{ printf("Divide 0,error!");

getch();

return ;

}

result=/**/ fun(x,y,z) /**/;

printf("\nResult=%.2f\n",result);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void chg(char s[])

{int i;

/**/ i=1 /**/;

while(s[i]!='\0')

{if ((s[i]>='A' && s[i]<='Z') && /**/ i%2 /**/)

/**/ s[i]=s[i]-32; /**/

i++;

}

}

void main()

{

char str_s[100];

printf("Enter string: ");

gets(str_s);

chg(str_s);

printf("\nNow string is:");

puts(str_s);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

int fun(/**/ char p /**/)

{int x;

/**/ x=1; /**/

while(*p)

{x=x*8+*p-'0';

p++;

}

return(/**/ *p /**/);

}

void main()

{

char str_s[6];

printf("Enter string: ");

gets(str_s);

printf("\nDecimal is: %d",fun(str_s) );

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void main()

{

char str[100];

char *p;

p=str;

scanf("%s",str);

while ( /**/*p=='\0' /**/)

p++;

printf(/**/"The length is:

getch();

}

%s "/**/,p-str);

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void main()

{ int i,gw,sw,sum=0;

for(i=1;i<100;i++)

{

sw=i/10;

gw= /**/ i-sw /**/;

if((gw==3 || gw==5)||(sw==3 || sw==5))

/**/ sum=i /**/;

}

printf("\nThe sum is:%d",sum);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

#include <math.h>

void fun(/**/ float a, b, c /**/)

{double s,area;

if(a+b>c && a+c>b && b+c>a)

{/**/ s=a+b+c/2; /**/

area=/**/ sqt(s*(s-a)*(s-b)*(s-c)) /**/ ;

printf("area=%7.2f\n",area);

}

else

printf("Not a triangle.\n");

}

void main()

{

float a,b,c;

printf("Input a,b,c:");

scanf("%f,%f,%f",&a,&b,&c);

fun(a,b,c);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void main()

{

int i,num[100],count;

/**/ count=1 /**/;

for(i=1000; i<=2000; i++)

if(/**/ (i-2)%4 = 0 && (i-3)%7=0 /**/)

{

num[count]=i;

count++;

}

printf("Total number is:%d\n", count );

for(i=0; /**/i<=count /**/;i++)

printf("%d\n", num[i]);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void swap(int *p, /**/ *q /**/)

{

int temp;

/**/ *temp /**/= *p;

/**/ *q = *p; /**/

*q = temp;

}

void main()

{

int a,b;

printf("Input 2 numbers:\n");

scanf("%d%d",&a,&b);

printf("\nOriginal: a=%d b=%d\n",a,b);

swap(&a,&b);

printf("Now: a=%d b=%d\n",a,b);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

填空题

/**/ /**/<stdio.h>

void main()

{

char str[100];

int /**/ /**/;

printf("Input string :");

gets(str);

for(i=j=0; str[i]!='\0'; i++)

{if(str[i]!='b')

{str[j]=str[i];

/**/ /**/;

}

}

str[j]='\0';

printf("Now string is:");

puts(str);

getch();

}

最新福建省计算机等级考试二级C语言考试题库

#include <stdio.h>

void main()

{

struct stu …… 此处隐藏:2641字,全部文档内容请下载后查看。喜欢就下载吧 ……

最新福建省计算机等级考试二级C语言考试题库.doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219