Advertisement
Centipede18

DemSoLanXuatHien

Mar 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. using namespace std;
  6.  main()
  7. {
  8.     int i, j;
  9.     char s[100];
  10.     int ts[100];
  11.     cout << " Nhap dong chu : " ; gets(s);
  12.     for( i=0;i<strlen(s);i++){
  13.         ts[i]=1;
  14.     }
  15.     for(i=0; i<strlen(s); i++){
  16.         for( j=i+1; j<strlen(s); j++){
  17.             if (s[i]==s[j] && ts[i]!=0)
  18.             {
  19.                 ts[j]=0;
  20.                 ts[i]++;
  21.             }
  22.         }
  23.     }
  24.     for(i=0;i<strlen(s);i++){
  25.         if(ts[i]!=0){
  26.             cout << " Ki tu " << s[i]<< " xuat hien " << ts[i] << " lan\n";
  27.         }
  28.     }
  29. //  getch();
  30. return 0;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement