-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.cpp
More file actions
33 lines (30 loc) · 776 Bytes
/
4.cpp
File metadata and controls
33 lines (30 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# include <iostream>
using namespace std;
# define NO_OF_CHARS 256
class duplicate_char{
public :
void charCounter(char *str, int *count){
int i;
for (i = 0; *(str + i); i++)
count[*(str + i)]++;
}
void printDuplicateCharacters(char *str){
int *count = (int *)calloc(NO_OF_CHARS, sizeof(int));
charCounter(str, count);
int i;
for (i = 0; i < NO_OF_CHARS; i++)
if(count[i] > 1)
printf("%c\t\t %d \n", i, count[i]);
free(count);
}
};
int main(){
duplicate_char dupchar ;
char str[]="";
printf("Masukkan kata : ");
scanf("%s", &str);
cout<<"The duplicate characters in the string\n";
cout<<"character\tcount\n";
dupchar.printDuplicateCharacters(str);
return 0;
}