8 Respostas
+ 1
Vishal If there is 10 then it's doesn't mean it is one zero. It should be "ten". So first you have to replace 10 with "ten"
2nd May 2021, 8:10 AM
A͢J
A͢J - avatar
0
#include <stdio.h> #include <string.h> int main() { char arr[100]; fgets(arr, sizeof(arr), stdin); int s= strlen(arr); for(int i=0; i< s; i++){ if(arr[i] >= 48 && arr[i]<=57){ goto num; } printf ("%c", arr[i]); num: if(arr[i] >= 48 && arr[i]<=57){ switch (arr[i]) { case '0': printf ("zero"); break; case '1': printf ("one"); break; case '2': printf ("two"); break; case '3': printf ("three"); break; case '4': printf ("four"); break; case '5': printf ("five"); break; case '6': printf ("six"); break; case '7': printf ("seven"); break; case '8': printf ("eight"); break;
2nd May 2021, 8:07 AM
Vishal
Vishal - avatar
0
case '8': printf ("eight"); break; case '9': printf ("nine"); break; case '10': printf ("ten"); break; } } } return 0; }
2nd May 2021, 8:08 AM
Vishal
Vishal - avatar
0
Test case 3 not passed
2nd May 2021, 8:08 AM
Vishal
Vishal - avatar
0
YUGRAJ STILL NOT GETTING if(arr[i] >= 48 && arr[i]<=57){ goto num; } printf ("%c", arr[i]); num: if(arr[i] >= 48 && arr[i]<=57){ if(arr[i] == '1' && arr[i+1]== '0'){ printf ("ten"); } switch (arr[i]) { case '0': printf ("zero"); break; case '1': printf ("one");
2nd May 2021, 2:22 PM
Vishal
Vishal - avatar
0
Yeah right now just put i++; and continue after printing ten
2nd May 2021, 4:47 PM
YUGRAJ
0
YUGRAJ BUDDY, I have tried it but it didn't work out also changed position sometimes of the statement but nothing happened.
2nd May 2021, 5:35 PM
Vishal
Vishal - avatar
- 1
For 10 you have to do two things it should be above all cases and second you need to check two characters so i recommend use if statement before switch and check if current is 1 and next is 0 if so then put ten in answer and increase i one time extra and then continue
2nd May 2021, 10:48 AM
YUGRAJ