Sort by

recency

|

1197 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    int main() {

    I think this way is a lot **simpler** than some other comments i read
    
    
        int array[10] = {0};
    int c = getchar();
    while( c != EOF){
        if(c >= '0' && c <= '9'){
            array[c-'0'] ++;
        }
        c = getchar();
    }
    for(int i=0;i<10;i++){
        printf("%d ",array[i]);
    }
    return 0;
    

    }

  • + 0 comments

    include

    include

    int main() {

    char *a=malloc(100*sizeof(char)); scanf("%s",a);

    for(int i=0;i<=9;i++){ int count=0; for(int j=0;a[j]!='\0';j++){ if(a[j]=='0'+i){ count++; } } printf("%d ",count); } return 0; }

  • + 1 comment

    char str[1000]; scanf("%s",str); int i,n0=0,n1=0,n2=0,n3=0,n4=0,n5=0,n6=0,n7=0,n8=0,n9=0;

     while(str[i]!='\0')
     {
        if(str[i]=='0')
        {
            n0++;
        }
    
         if(str[i]=='1')
        {
            n1++;
        }
         if(str[i]=='2')
        {
            n2++;
        }
         if(str[i]=='3')
        {
            n3++;
        }
         if(str[i]=='4')
        {
            n4++;
        }
         if(str[i]=='5')
        {
            n5++;
        }
         if(str[i]=='6')
        {
            n6++;
        }
         if(str[i]=='7')
        {
            n7++;
        }
         if(str[i]=='8')
        {
            n8++;
        }
         if(str[i]=='9')
        {
            n9++;
        }
    
    
      i++;  
    
    
    
     }
    

    printf("%d %d %d %d %d %d %d %d %d %d",n0,n1,n2,n3,n4,n5,n6,n7,n8,n9);

  • + 0 comments

    This task focuses on iterating through a mixed alphanumeric string and counting how often each digit from 0 to 9 appears, regardless of letter placement. It’s a straightforward frequency-mapping exercise, similar in clarity to following a camberley airport taxi route where each stop is accounted for once.

  • + 0 comments

    The approach of counting each digit’s frequency is straightforward and effective, much like planning a smooth pet transport canada route where every step is tracked carefully.