更多"由键盘输入上档字符应按下______键,______键的功能是锁定键盘"的相关试题:
[简答题]【说明】
以下程序的功能是:从键盘上输入一个字符串,把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来。
【程序】
#include < stdio. h >
main( )
FILE * fp;
char str[100]; int i=0;
if((fp=fopen("text.txt" (1) )) ==NULL)
printf("can’t open this file. /n") ;exit(0) ;
printf(" input astring: /n" ); gest(str);
while( str[i] )
if(str[i] >=’a’ && str[i] <=’z’)
str[i]= (2) ;
fputc(str[i], (3) );
i++;
fclose(fp);
fp=fopen(" test.txt", (4) );
fgets(str, 100, fp);
printf("%s/n" ,str);
(5) ;
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main( )
int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("*** original string ***/n");
puts(str);
【1】 ;
while(*(pf+j)).
if(*(pf+j)>=’a’&&* (pf+j)<=’z’)
*(pf+j)= 【2】 ;
j++;
else
【3】 ;
printf("****** new string ******/n");
puts(str);
system("pause");
[简答题]以下程序从键盘读取一个字符串以‘#’作为结束,再将字符串中的小写英文字母改写成大写英文字母,最后将改写好的字符串写入磁盘文件file.txt,请将程序补充完整。
注意:不改动程序结构,不得增行或删行。
package ch3;
import java.io.*;
class File1
private char ch;
private int i=’a’-’A’;
void savetoFile( )
System.out.println("请输入一个字符串:");
try
______out=new______("ch3/file.txt");
while((ch=(char)System.in.______( )) !=’#’)
if(ch >=’a’ && ch <=’z’)
ch=(char) ((int)ch-i);
out.______;
out.close( );
catch(IOException e)
e.printStackTrace( );
public class ex3
public static void main(String[] args)
File1 obj=new File1( );
Obj.savetoFile( );
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
{
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
}
int fun(char *str)
{
//**********
}
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
int fun(char *str)
//**********
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<ctype.h>
main( )
{
int i=0;
char a [81];
char *p=s;
clrscr ( );
printf{" Input a string /n");
for (i=0; i<80; i++)
{
s [i] =getchar ( );
if (s [i]==’/n’)
【1】;
}
s[i]= 【2】
printf(" display the string /n");
while (*p)
putchar (【3】 );
}
[填空题]在执行KeyPress事件过程时,KeyASCII是所按键的 【8】 值。对于有上档字符和下档
字符的键,当执行KeyDown事件过程时,KeyCode是 【9】 字符的ASCII值。