+ 2
c code to find digit frequency?
Code to find digit frequency from the string which contains both characters and integers.
6 Respostas
+ 1
#include<stdio.h>
#include<string.h>
int main()
{
char str[1001];
scanf("%s", str) ;
int lut[10]={0, };
for(int i=0;i<strlen(str);++i);{
if(str[i] >='0'&&str[i] <='9')
{
++lut[str[i] - '0'];
}
}
for(int i=0;i<10;++i) {
printf("%d", lut[i]) ;
}
return 0;
}
+ 5
which language are you writing with??? I mean programing
+ 4
Please show us your attempt.
+ 3
you can link the code you have written, but it fails to work the way you want it, that might be good for a start
+ 1
string is an array of characters, you can use a loop and to the freq.
string s="uhdu-638-38-33";
int f3=0;
for(int i=0; i<s.size(); i++) {
if(s[i]=='3') f3++;
}
0
Use a search algorithm