33,311
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<ctype.h>
int converse(char ch);
int main(){
char ch;
int position;
while((ch = getchar())!= EOF){
position = converse(ch);
if( position == -1)
printf("%c is not a letter in alphabet.\n",ch);
else
printf("The position of letter %c in alphabeta is %d.\n",ch,position);
}
printf("Done.\n");
return 0;
}
int converse(char ch){
int ret;
if(isalpha(ch)){
if(ch >= 65 && ch <= 90)
ret = ch - 64;
else
ret = ch - 97;
}
else
ret = -1;
//忘记了写 return ret;
}