计算机三级上机题库百度云,计算机三级上机题库100例

if(b[i]

b[j]=qw;}

}

void readDat()

{

int i ;

FILE *fp ;

fp = fopen("in.dat", "r") ;

for(i = 0 ; i < MAX ; i++) fscanf(fp, "%d", &a[i]) ;

fclose(fp) ;

}

void main()

{

int i ;

readDat() ;

jsVal() ;

printf("满足条件的数=%d\n", cnt) ;

for(i = 0 ; i < cnt ; i++) printf("%d ", b[i]) ;

printf("\n") ;

writeDat() ;

}

writeDat()

{

FILE *fp ;

int i ;

fp = fopen("out.dat", "w") ;

fprintf(fp, "%d\n", cnt) ;

for(i = 0 ; i < cnt ; i++) fprintf(fp, "%d\n", b[i]) ;

fclose(fp) ;

}

★☆题目3(无忧id 133题;捷成id 59、99字符串

位置倒置题)

函数ReadDat( )实现从文件IN.DAT中读取一篇英文

文章存入到字符串数组xx中;请编制函数

StrOR( ),其函数的功能是:以行为单位依次把

字符串中所有小写字母o左边的字符串内容

移到该串的右边存放,然后把小写字母o删

除,余下的字符串内容移到已处理字符串的

左边存放,之后把已处理的字符串仍按行重

新存入字符串数组xx中。最后main()函数调用

函数WriteDat()把结果xx输出到文件OUT5.DAT中。

例如:原文:n any field.Yu can create an

index

you have the correct

record.

结果:n any field. Yu can create

an index

rd. yu have the crrect rec

原始数据文件存放的格式是:每行的宽度均小于

80个字符,含标点符号和空格。

注意:部分源程序存放在文件prog1.c中。

请勿改动主函数main()、读数据函数ReadDat()

和输出数据函数WriteDat()的内容。

#include

#include

#include

char xx[50][80] ;

int maxline = 0 ; /* 文章的总行数*/

int ReadDat(void) ;

void WriteDat(void) ;

void StrOR(void)

{int i,righto,j,s,k;

char tem[80];

for(i=0;ifor(j=strlen(xx[i])-1;j>=0;j--)

{ k=0;

memset(tem,0,80); /*初始化字符串数

组tem*/

if(xx[i][j]=='o') /*如果当前字符为'o',

进入以下语句*/

{righto=j; /*则将此字符中位置j的

值赋给righto*/

for(s=righto+1;stem[k++]=xx[i][s]; /*从righto

的下一跳开始将其后所有的字符都存入到tem中*/

for(s=0;s行首部开始到出现字符'o'的位置(righoto)之前开始

循环*/

if(xx[i][s]!='o')

tem[k++]=xx[i][s]; /*将不是字符'o'的字符全存入

到tem中*/

strcpy(xx[i],tem); /*将当前已处

理的字符重新存入当前行xx*/

}

else continue;

}

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\n\007") ;

return ;

}

StrOR() ;

WriteDat() ;

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值