下列程序用于将源文件中的字母进行大小写转换,while的条件是【 】。
include<iostream. h>
include<fstream. h>
include<iomanip. h>
void main( )
}
char ch;
fstream filel, file2
char fn1[10], fn2[10];
cout<<"输入源文件名:";
cin>>fn1
cout<<"输入目标文件名:";
tin>>fn2
file1, open(fn1 ,ios: :in);
file2, open(fn2, ios:: out);
while(________)
{
if(ch>='a'&&ch<='z')
ch=ch-'a'+'A',
file2, put(ch),
}
file1, close(),
file2, close();
}
第1题:
下列给定程序中,函数fun()的功能是;将s所指字符串中的字母转换为按字母序列的后续字母(但Z转化为A,z转化为 a),其他字符不变。
请改正函数fun()中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <ctype.h>
include <conio.h>
void fun(char *s)
/*************found**************/
{ while(*s!='@')
{ if(*s>='A' &*s<='z'||*s>='a'&&*s<='z')
{if(*s=='Z') *S='A';
else if(*S=='z') *s='a';
else *s+=1;
}
/*************found**************/
(*s)++;
}
}
main()
{ char s[80];
clrscr();
printf("\n Enter a string with length <80:\n\n");gets(s);
printf("\n The string:\n\n");puts(s);
fun(s);
printf("\n\n The Cords:\n\n");puts(s);
}
第2题:
下列程序是输入一个小写字母,转换成对应大写字母的后一个字母输出。例如:'a'将转换成'B'、…、'y'将转换成'Z',其中的'z'将转换成'A'。请填写程序中所缺少语句: #include<stdio.h> void main() { char ch; scanf("%c", &ch); ch=ch-32+1; printf("%cn", ch); }
第3题:
当执行以下程序时,输入 1234567890< 回车 > ,则其中while循环中的printf("#")将执行___次. #include <stdio.h> int main() { char ch; while((ch=getchar())=='0') printf("#"); return 0; }
第4题:
下列给定程序中,函数fun()的作用是:将字符串tt中的小写字母都改为对应的大写字母,其他字符不变。例如,若输入“edS,dAd”,则输出“EDS,DAD”。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <string.h>
include <conlo.h>
/*************found*************/
char fun(char tt[ ])
{
int i;
for(i=0;tt[i];i++)
{
/*************found*************/
if((tt[i]>='A')&&(tt[i]<='2'))
tt[i]-=32;
}
return(tt);
}
main()
{
int i;
char tt[81];
clrscr();
printf("\nPlease enter a string:");
gets(tt);
printf("\nThe result string iS:/n%s", fun(tt));
}
第5题:
【填空题】下面程序的运行结果是 。 #include<stdio.h> #include<string.h> main() {char a[20]="AB",b[20]="LMNP"; int i=0;strcat(a,b); while(a[i++]!='0') b[i]=a[i]; puts(b); }