更多"下面程序的功能是把文件file1.txt中重复字符去掉后(即若有多个字"的相关试题:
[填空题]下面程序的功能是用来统计文件中字符个数。请填空。
#include"stdio.h"
main( )
long count=OL;
FILE*fp= 【16】 ("text.dat","r");
if(fp==0)
printf("Open error/n");
exit(0);
while( 【17】 )
fgetc(fp);
count++;
fclise(fp);
printf("%1d/n",count);
[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class InputString{
public static void main(String args[ ]){
String stringname= new _______________ ("ABCDEFGH");
for(int i= _______________ i>=0;i--)
System.out.println(String.valueOf(stringname.________________));
}
}
[填空题]下面程序的功能是将字符串s中所有的字符a删除。请填空。
#include<stdio.h>
void main( )
{char s[80];
int i,j=0;
gets(s);
for(i=0;s[i]!=’/0’;i++)
if(s[i]!=’a’)______;
s[j]=’/0’;
puts(s);}
[填空题]下面程序的预设功能是:统计文件abc.txt中的字符个数。
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main( )
fstream file;
file.open( "abc.txt", ios::in);
if ( !file )
cout<<"Can not open abc.txt"<<end1;
abort( );
char ch;
int i = O;
while (______________)
file.get(ch);
i++;
cout<<"Characters : "<<i<<end1;
file.close( );
则程序中空白处应该填入的语句是 【15】 。
[填空题]下面程序的功能是将字符串s中所有的字符c删除,补足所缺语句。
#include<stdio.h>
main( )
char s[80];
int i,j;
gets(s);
for(i=j=0;s[i]!=’/0’;i++)
if(s[i]!=’c’) 【10】 ;
s[j]=’/0’;
puts(s);
[填空题]下面程序的功能是将字符串s中的每个字符按升序的规则插到数组a中,字符串a已排好序。
#include<stdio.h>
#include<string.h>
void main( )
char a[20]="cehiknqtw";
char s[]="fbla";
int i,k,j;
for(k=0;s[k]!=’/0’;k++)
j=0;
while(s[k]>=a[j]&&a[j]!=’/0’)
j++;
for(______)
______;
a[j]=s[k];
puts(a);
[单项选择]下面程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是 public class FindKeyWords{ public static void main(String[]args) { String text="An array is a data structur that stores a collection of" +"values of the same type. You access each indMdual value" +"through an integer index. For example,if a is an array" +"of inergers,then a[i]is the ith integer in the array."; int arrayCount=0; int index=-1; String arrayStr="array"; index=text.indexOf(arrayStr); while(index>=0) { ++arrayCount; index+=arrayStr.length( ); index=text.indexOf(arrayStr,index); } System.out.println("the text contains"+arrayCount+"arrays"); } }
A. <
B. =
C. <=
D. >=
[填空题]下面程序可用来统计文件中字符的个数。
#include<stdio.h>
main( )
{FILE *fp;
long num=0;
if((fp=______)==NULL)/*第一空*/
{printf("Can not open file/n");exit(0);}
while(______)/*第二空*/
{______;}/*第三空*/
printf("num=%d/n",num);
fclose(fp);
}
[填空题]下面程序的功能是统计字符串中“i”的个数请填空。
Sub COU( )
Dim n As Integer
a$ =" Beijing University of Technology"
n = Len(a$)
For i = 1 To n
b$ = 【15】
If b$ ="i" Then x=x+1
Next
Print" x="; x
End Sub
[填空题]【说明】
下面的程序功能的功能是以行为单位对字符串按下面的条件进行排序。排序条件为:从字符串中间一分为二,右边部分按字符的ASCII值降序排序,排序后左边部分与右边部分进行交换。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上
例如:位置:0 1 2 3 4 5 6 7
源字符串:h g f e a b c d
则处理后字符串:d c b a h g f e
函数ReadDat( )实现从文件in.dat中读取数据(每行字符串长度均小于80),函数WriteDat( )把结果dat输出到文件out.dat中。
#include<stdio.h>
#include<siring.h>
#include<conio.h>
char dat[20] [80];
void jsSort( )
int i,j,k,strl;
char ch;
for(i=0;i<20;i++)
strl=strlen(date[i]);
for(j= (1) ;j<strl;j++) /*对后半部分的字符串进行排序*/
for(k=j+1;k<strl;k++)
if( (2) )
ch=dat[i] [j];
dot[i] [j]=dat[i] [k];
dat[i] [k]=ch;
for(j=0; (3) j++) /*前后两部分进行交换*/
ch = date [i] [j];
dote [i] [j] = date [i] [(strl+1)/2+j];
dat [i] [(strl+1)/2+j]=ch;
void main( )
reodDat( );
isSort( );
writeDot(
[简答题]下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。
注意;请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
public class CharAtOp{
public static void main(String args[ ]){
String str="abcdef";
int size=
System.out.println("字符串str的长度为: "+size);
for(int m=0;___________________m++)
{
_______________________
System.out.println("str中的第"+m+"个字符是: "+c);
}
}
}