We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Arrays and Strings
- Digit Frequency
- Discussions
Digit Frequency
Digit Frequency
Sort by
recency
|
1197 Discussions
|
Please Login in order to post a comment
include
include
include
include
int main() {
}
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; }
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;
printf("%d %d %d %d %d %d %d %d %d %d",n0,n1,n2,n3,n4,n5,n6,n7,n8,n9);
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.
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.