-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextchuoi.cpp
More file actions
47 lines (47 loc) · 818 Bytes
/
Copy pathtextchuoi.cpp
File metadata and controls
47 lines (47 loc) · 818 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <conio.h>
#include <string.h>
int xoakitu(char s[], int vitrixoa){
for (int i=vitrixoa; i<strlen(s); i++){
s[i]=s[i+1];
}
}
int xoatrungnhau(char s[]){
for (int i=0; i<strlen(s); i++){
for (int j=i+1; j<strlen(s); j++){
if (s[i]==s[j]){
xoakitu(s,j); j--;
}
}
}printf ("%s", s);
}
int dem(char *s, char x){ int dem=0;
for (int i=0; i<strlen(s); i++){
if (s[i]==x){
dem++;
}
}return dem;
}
int main()
{
char s[100];
gets(s); char *c;
c=strdup(s);
///*
//c=(char *)malloc(strlen(s));
///strcpy(c,s);
//*/
xoatrungnhau(s);
char *d;
d=strdup(s);
printf ("\n");
for (int i=0; i<strlen(d); i++){
printf (" %c co %d ki tu tai vi tri: ", d[i], dem(c,d[i]));{
for (int j=0; j<strlen(c); j++){
if (d[i]==c[j]){
printf ("%d\t", j);
}
}printf ("\n");
}
}
}