Sort by

recency

|

1180 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
    char s[1000];
    int freq[10] = {0}; 
    
    scanf("%[^\n]", s); 
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            freq[s[i] - '0']++;
        }
    }
    
    for (int i = 0; i < 10; i++) {
        printf("%d ", freq[i]);
    }  
    return 0;
    

    }

  • + 0 comments

    int main() {

    char *s;
    int i, NumberCounter[10] = {0,0,0,0,0,0,0,0,0};
    s = malloc(1024 * sizeof(char));
    scanf("%[^\n]", s);
    
    
    for (i=0;s[i]!='\0';i++)
    {            
      if (isdigit(s[i]))              
         ++NumberCounter[s[i]-'0'];                    
    }
    
    for (i=0; i<10;i++)
      printf ("%d ", NumberCounter[i]);
    

    return 0; }

  • + 0 comments

    used the longest method possible😁😁

    include

    include

    include

    include

    include

    int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
    char str[1000];  
    scanf("%s",str);
    int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,m=0,j=0;
    for(int i=0;i<strlen(str);i++){
        if (isdigit(str[i])){
            if (str[i]=='0'){
                a++;
            }
            if (str[i]=='1') {
                b++;
            }
            if (str[i]=='2'){
                c++;
            }
            if (str[i]=='3'){
                d++;
            }
            if (str[i]=='4'){
                e++;
            }
            if (str[i]=='5'){
                f++;
            }if (str[i]=='6'){
                g++;
            }if (str[i]=='7'){
                h++;
            }if (str[i]=='8'){
                m++;
            }if (str[i]=='9'){
                j++;
        }
    }
    }
    printf("%d %d %d %d ",a,b,c,d);
    printf("%d %d %d %d %d %d",e,f,g,h,m,j);
    return 0;
    

    }

  • + 0 comments

    int main() {

    int count[10] = {0};
    int i;
    char *num = malloc(1000 * sizeof(char));
    
    fgets(num, 1000, stdin);
    
    while (*num != '\0'){
        if (isalnum(*num))
            count[*num - '0']++;
        *num++;    
    }
    for (i = 0; i < 10; i++)
        printf("%d ", count[i]);
    
    return 0;
    

    }

  • + 0 comments

    include

    include

    include

    include

    int main(void){ char* arr = (char*)malloc(1000*sizeof(char)); int *finalDigit = (int )calloc(1000, sizeof(int)); if (finalDigit == NULL) { printf("Memory allocation failed\n"); return 1; } scanf("%s", arr); int digit = (int *)malloc(1000*sizeof(int)); int len = strlen(arr), digitCount=0; for(int i = 0;i