计算机省二c语言编程改错题,福建省计算机二级考试C语言上机题库改错填空编程...

{if(/**/ minmax)

/**/ max=a[i][j] /**/ }

printf(\ getch(); }

Cmody212.c

修改程序cmody212.c,实现从键盘输入一串字符和一个字串,输出该子串在原字符串中出现的次数。 #include #include void main()

{

int i,j,k,count;

char s1[100],s2[100]; printf(\ gets(s1);

printf(\ gets(s2); count=0;

/**/ for(i=0;*s1!='\\0';i++) /**/ { /**/ for(k=0; (s1[j]==s2[k])&&(s1[j]!='\\0'); j++,k++ ); /**/

if(s2[k]=='\\0') count++; }

printf(\ getch(); }

Cmody221.c

修改程序,输出存储在结构体数组中8位学生成绩的平均分以及最高学生的姓名

#include

/**/ structure student /**/ {

char name[10]; float score; };

void main( ) {

struct student stu[8]={{\{\Yili\ int i=0,mrk;

float total=0,aver,max; max=stu[0].score; mrk=0; while(i<8) {

/**/ total=total+stu[i]; /**/ if(stu[i].score>max) {max=stu[i].score; mrk=i; }

/**/ i++ /**/ }

aver=total/8;

printf(\\\n Best is %s\\n\ getch(); }

Cmody222.c

修改程序,完成其中n个字符串的升序排列

#include #include #define ROW 5 #define COL 30

void fun(char s[][COL],int n) {

char temp[COL]; int i,j;

for(i=0; i/**/ for (j=i+1; j0)

{

strcpy(temp,s[i]); strcpy(s[i],s[j]); strcpy(s[j],temp); } }

void main() {

int i; char

str[][COL]={\ME\APMAE\/**/ fun(str,COL); /**/ clrscr();

for(i=0;iprintf(\ getch(); }

Cmody231.c

修改程序cmody231.c,实现将输入的十进制正整数转换成十六进制数,且用字符串存放该十六进制数 #include #include #include void main() {

int x,b,i,j; char s[5];

printf(\ scanf(\ /**/ i=1; /**/ while(x>0) {b=x; if(b>9)

s[i]=b-10+'A'; else

/**/ s[i]=b /**/; x=x/16; i++; }

printf(\ for(j=i-1;j>=0;j--)

putchar(/**/ s[i] /**/); getch(); }

Cmody232.c

修改程序cmody232.c,输出下列9行数字金字塔 1 121 12321 1234321 ………………………

12345678987654321 #includevoid main() {

int i,j,k;

for(k=1;k<=9;k++) {

/**/ for(i=0;i<=k;i++) /**/ printf(\ for(i=1;i<=k;i++) printf(\ /**/ for(j=k-1;j>1;j--) /**/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值