程序填空题:学英语(按字母说序号)
学英语(按字母说序号)
为教会大家念英文字母,老师做了一张字母表,给字母编上序号。老师随机念出字母,让大家说出对应的序号。

下面的程序输入字母(大写或小写),输出对应的序号。
请在空白处填写适当内容完成该程序。
c
#include <stdio.h>
#include <ctype.h>
int main()
{
char letter;
int number;
scanf(" %c", &letter);
number = ;
printf("%d\n", number);
return 0;
}
提示:利用 toupper 或 tolower 函数将字母转为大写或小写。
#### 输入样例1
in
E
#### 输出样例1
out
5
#### 输入样例2
in
e
#### 输出样例2
out
5
---
相关习题:学英语(按序号念字母)。
答案:
第1空:tolower(letter) - 'a' + 1
为教会大家念英文字母,老师做了一张字母表,给字母编上序号。老师随机念出字母,让大家说出对应的序号。

下面的程序输入字母(大写或小写),输出对应的序号。
请在空白处填写适当内容完成该程序。
c
#include <stdio.h>
#include <ctype.h>
int main()
{
char letter;
int number;
scanf(" %c", &letter);
number = ;
printf("%d\n", number);
return 0;
}
提示:利用 toupper 或 tolower 函数将字母转为大写或小写。
#### 输入样例1
in
E
#### 输出样例1
out
5
#### 输入样例2
in
e
#### 输出样例2
out
5
---
相关习题:学英语(按序号念字母)。
答案:
第1空:tolower(letter) - 'a' + 1