Stu*_*Stu 0 c if-statement equality conditional-statements
我试图在这里解决问题,但我不知道为什么我的代码不起作用.任何帮助表示赞赏.编辑:编辑进行下面提到的修正,但在输出的第二行还有一个额外的"15"(粗体),我不明白它来自哪里.
我的输出是
18662658515 5552272 15
#include <stdlib.h>
#include <stdio.h>
int main(void){
int n;
int j;
scanf("%d\n", &n);
int i = 0;
char mystr[15];
for(;i<n;i++){
fgets(mystr,15,stdin);
for(j=0;j<15;j++){
if(isdigit(mystr[j])){
printf("%c", mystr[j]);
continue;
}
if ('A' <= mystr[j] && mystr[j] <= 'C')
printf("2");
if ('D' <= mystr[j] && mystr[j] <= 'F')
printf("3");
if ('G' <= mystr[j] && mystr[j] <= 'I')
printf("4");
if ('J' <= mystr[j] && mystr[j] <= 'L')
printf("5");
if ('M' <= mystr[j] && mystr[j] <= 'O')
printf("6");
if ('P' <= mystr[j] && mystr[j] <= 'S')
printf("7");
if ('T' <= mystr[j] && mystr[j] <= 'V')
printf("8");
if ('W' <= mystr[j] && mystr[j] <= 'Z')
printf("9");
}
printf("\n");
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
265 次 |
最近记录: |