a11472o5t6
Sample Output 0
0 2 1 0 1 1 1 1 0 0
Sample Input 1
lw4n88j12n1
Sample Output 1
0 2 1 0 1 0 0 0 2 0
Sample Input 2
1v88886l256338ar0ekk
Sample Output 2
1 1 1 2 0 1 2 0 5 0
Solution in C:-
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int* nums = (int*) malloc(10 * sizeof(int));
char c;
for(int i = 0; i < 10; i++)
*(nums+i) = 0;
while(scanf("%c", &c) == 1)
if(c >= '0' && c <= '9')
(*(nums+(c-'0')))++;
for(int i = 0; i < 10; i++)
printf("%d ", *(nums+i));
return EXIT_SUCCESS;
}
No comments:
Post a Comment
Thanks..