从键盘上读取字符,后将这一字符的下一字符显示在屏幕上(如用户输入为A,则显示B).共循环接收20个

来源:百度知道 编辑:UC知道 时间:2024/05/12 12:17:02
这是编程题

#include<iostream.h>
#include<afxwin.h>
void main()
{
char chararray[20];
memset(chararray,0,sizeof(chararray));
for(int i = 0; i < 20;i ++)
{
cout << "请你输入第" << i + 1 << "个字符" << endl;
cin >> chararray[i];

}
for(int j = 0; j < 20;j ++)
{
cout << char(chararray[j] + 1) << endl;
}

}

Private Sub Form_KeyPress(KeyAscii As Integer)
Static count As Integer
If count < 20 Then
Print Chr(KeyAscii + 1)
End If
count = count + 1
End Sub

很简单,用PASCAL遍程序如下
program lx;
var
x:char;
begin
readln(x);
write(chr(ord(x)+1));
end.
用C程序如下
Private Sub Form_KeyPress(KeyAscii As Integer)
Static count As Integer
If count < 20 Then
Print Chr(KeyAscii + 1)
End If
count = count + 1
End Sub