更多"函数readDat( )是从文件IN.DAT中读取20行数据存放到字符"的相关试题:
[简答题]函数readDat ( )是从文件in71.dat中读取20行数据存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数jsSort( ),其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存八字符串数组xx中。最后调用函数writeDat( )把结果xx输出到文件out71.dar中。
条件:从字符串中间一分为二,左边部分按字符的ASCII值降序排序,右边部分按字符的ASCII值升序排序。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。
例如: 位置 0 1 2 3 4 5 6 7 8
源字符串 a b c d h g f e
1 2 3 4 9 8 7 6 5
处理后的字符串 d c b a c f g h
4 3 2 1 9 5 6 7 8
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
# include <stdio.h>
# include <string.h>
# include <conio. h>
char xx[20] [80];
void jsSort( )
void main ( )
readDat ( );
jsSort ( );
writeDat ( );
readDat ( )
FILE *in;
int i=0;
char *p;
in=fopen("in71.dat","r");
while (i<20 && fgets(xx[i],80,in) !=NULL)
p=strchr(xx[i], ’/n’);
if (p)
*p= 0;
i++;
fclose (in);
writeDat
[多项选择]函数readDat( )是从文件in71.dat中读取20行数据存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数JsSon( ),其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中。最后调用函数writeDat( )把结果xx输出到文件out71.dat中。
条件:从字符串中间一分为二,左边部分按字符的ASCⅡ值降序排序,右边部分按字符的ASCⅡ值升序排序。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。
例如: 位置0 1 2 3 4 5 6 7 8
源字符串a b c d h g f e
1 2 3 4 9 8 7 6 5
处理后的字符串d c b a e f g h
4 3 2 1 9 5 6 7 8
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDatO的内容。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char xx[20][80];
void isSoYt( )
void main( )
readDat( );
isSort( );
writeDat( );
readDat ( )
FILE *in;
int i=0;
char *p;
in=fopen ("in71.dat", "r");
while (i<20 && fgets(xx[i],80,in)!=NULL)
p=strchr (xx [i] , ’/n’ );
if (p)
*p=0;
i++;
fclose (in);
writeDat ( )
FILE
[简答题]函数ReadDat( )实现从in.dat文件中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编写函数jsSort( ),其函数的功能是:以行为单位对字符串按给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数WriteDat( ),把结果xx输出到out.dat文件中。
条件:从字符串中间一分为二,左边部分按字符的ASCII值降序排序,右边部分按字
符的ASCII值升序排序。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。
例如: 位置0 1 2 3 4 5 6 7 8
源字符串a b C d h g f e
1 2 3 4 9 8 7 6 5
则处理后字符串d C b a e f g h
4 3 2 1 9 5 6 7 8
注意:部分源程序已经给出。
请勿改动主函数main( )、读数据函数ReadDat( )和输出数据函数WriteDat( )的内容。
#include<stdio.h>
#include<string.h>
#include<conio.h>
char xx[20][80];
void jsSort( )
void ReadDat( )
FILE *in;
int i=0;
char *p;
in=fopen("in.dat","r");
while(i<20&&fgets(xx[i],80,in)!=NULL)
p=strchr(xx[i],’/n’);
if(p)
*p=0;
i++;
fclose(in);
void WriteDat( )
FILE *out;
int i;
out=fopen("out.dat","w");
for(i=0; i<20;i++)
printf("%s/n",xx[i]);
fprintf(
[简答题]函数readDat( )的功能是从文件in74.dat中读取20行数据存放到字符串数组xx中(每行字符串的长度均小于80)。请编制函数jsSort( ),该函数的功能是:以行为单位对字符串变量的下标为奇数位置上的字符按其ASCII值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数writeDat( )把结果xx输出到文件out74.dat中。
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char xx[20][80];
void readDat( );
void writeDat( );
void jsSort( )
void main( )
readDat( );
jsSort( );
writeDat( );
void readDat( )
FILE * in;
int i=0;
char * p;
in=fopen("in74.dat","r");
while(i<20 && fgets(xx[i],80,in)!=NULL)
p=strchr(xx[i],’/n’);
if(p)*p=0;
i + +;
fclose(in);
void writeDat( )
FILE * out;
int i;
out=fopen("out74.dat","w");
system("CLS");
for(i=0;i<20;i + +)
printf("% s/n",xx[i]);
fprintf(out,"% s/n",xx[i]);
fclose(out);
[简答题]函数readDat( )的功能是从文件IN22.DAT中读取20行数据存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数jsSort( ),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数writeDat( )把结果xx输出到文件OUT22.DAT中。
条件:从字符中间一分为二,左边部分按字符的ASCII值降序排序,排序后,左边部分与右边部分按例子所示进行交换。如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在原位置上。
例如, 位置 0 1 2 3 4 5 6 7 8
源字符串 a b c d h g f e
2 3 4 9 8 7 6 5
则处理后字符串 h g f e d c b a
8 7 6 5 9 4 3 2
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
#include<stdio. h>
#include<string. h>
#inc lude<conio, h>
char xx[20] [80]; void jsSort( )
main ( )
readDat ( );
jsSort ( );
writeDat ( );
readDat ( )
FILE *in;
int i=0;
char *p;
in= fopen("IN22.DAT","r");
while(i < 20 && fgets(xx[i], 80, in) != NULL)
p = strchr(xx[i], ’/n’);
if(p) *p = 0;
i++;
fclo
[多项选择]读函数readDat( )的功能是从文件IN25.DAT中读取20行数据存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数jsSort( ),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用写函数writeDat( )把结果xx输出到文件OUT25.DAT中。
条件:从字符串中间一分为二,左边部分按字符的ASCII值升序排序,排序后,左边部分与右边部分按例子所示进行交换。如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在原位置上。
例如: 位置 0 1 2 3 4 5 6 7 8
源字符串 d c b a h g f e
4 3 2 1 9 8 7 6
处理后字符串 h g f e a b c d
9 8 7 6 1 2 3 4
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
#include 〈stdio.h>
#include 〈string.h>
#include 〈conio.h>
char xx[20] [80]; void jsSort( )
main ( )
readDat ( );
jsSort ( );
writeDat ( );
readDat ( )
FILE *in;
int i=0;
char *p;
in = fopen("IN25.DAT", "r");
while(i〈20 && fgets(xx[i], 80, in) != NULL)
p = strchr(xx[i], ’/n’);
if(p) *p = 0;
i++;
fclose(in);
writeDat ( )
FILE *out
[简答题]函数readDat( )的功能是从文件in52.dat中读取20行数据存放到字符串数组xx中(每行字符串的长度均小于80)。请编制函数JsSort( ),该函数的功能是:以行为单位对字符串变量的下标为奇数位置上的字符按其ASCII值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数writeDat( )把结果xx输出到文件out52.dat中。
例如: 位置 0 1 2 3 4 5 6 7
源字符串 h g f e d c b a
则处理后字符串 h a f c d e b g。
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat和写函数writeDat( )的内容。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char xx[20] [80];
void jsSort( )
void main( )
readDat( );
jsSort( );
writeDat( );
readDat( )
FILE *in;
int i=0;
char *p;
in=fopen("in52.dat","r");
while(i<20 && fgets(xx[i],80,in)!=NULL)
p=strchr(xx[i],’/n’);
if(p) *p=0;
i++;
fclose(in);
writeDat ( )
FILE *out;
int i;
out=fopen("out52.dat","w");
clrscr( );
for(i=0;i<20;i++)
printf("%s/n",xx[i]);<
[简答题]函数readDat( )的功能是从文件IN75.DAT中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数jsSort( ),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数writeDat( )把结果xx输出到文件OUT75.DAT中。
条件:从字符串中间一分为二,左边部分按字符的ASCII值降序排序,排序后,左边部分与右边部分按例子所示进行交换。
如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在原位置上。
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char xx[20][80];
void readDat( );
void writeDat( );
void jsSort( )
void main( )
readDat( );
jsSort( );
writeDat( );
void readDat( )
FILE * in;
int i=0;
char * p;
in=fopen("in75.dat","r");
while(i<20 && fgets(xx[i],80,in)!=NULL)
p=strchr(xx[i],’/n’);
if(p)*p=0;
i + +;
fclose(in);
void writeDat( )
FILE * out;
int i;
system("CLS");
out=fopen("out74.dat","w");
for(i=0;i<20;i + +)
printf("%
[简答题]读函数readDat( )的功能是从文件IN76.DAT中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编制函数jsSort( ),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用写函数writeDat( )把结果xx输出到文件OUT76.DAT中。
条件:从字符串中间一分为二,左边部分按字符的ASCII值升序排序,排序后,左边部分与右边部分按例子所示进行交换。如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在原位置上。
注意:部分源程序已给出。
请勿改动主函数main( )、读函数readDat( )和写函数writeDat( )的内容。
试题程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char xx[20][80];
void readDat( );
void writeDat( );
void jsSort( )
void main( )
readDat( );
jsSort( );
writeDat( );
void readDat( )
FILE * in;
int i=0;
char * p;
in=fopen("in76.dat","r");
while(i<20 && fgets(xx[i],80,in)!=NULL)
p=strchr(xx[i],’/n’);
if(p)*p=0;
i + +;
fclose(in);
void writeDat( )
FILE * out;
int i;
system("CLS");
out=fopen("out76.dat","w");
for(i=0;i<20;i + +)
printf("% s/n
[简答题]
请编写函数fun, 函数的功能是:统计一行字符串中单词的个数,作为函数值返 回。一行字符串在主函数中输入, 规定所有单词由小写字母组成,单词之间由若干 个空格隔开, 一行的开始没有空格。
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入你编写的若干语句。
给定源程序:
#include
#include
#define N 80
int fun( char *s)
{
}
main( )
{ char line[N]; int num=0;
printf("Enter a string :/n"); gets(line);
num=fun( line );
printf("The number of word is : %d/n/n",num);
NONO( );
}
[简答题]有一个字符串,包含n个字符。写一个函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。要求在主函数中输入字符串及m值并输出复制结果。
[简答题]有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。
#include<iostream>
using namespace std;
void copystr(______)
int n=0;
while(n<m-1)
n++;
p1++;
while(*p1!=’/0’)
*p2=*p1;
p1++;
p2++;
*p2=’/0’;
void main( )
int m;
char str1[20],str2[20];
cout<<"输入字符串1:";
______
cout<<"从第m个字符开始复制,请输入m:";
cin>>m;
if(strlen(str1)<m)
cout<<"输入超过str1的长度"<<endl;
else
copystr(str1,str2,m);
cout<<"复制的字符串是:"<<str2<<endl;