Advertisement
_Kripaka001_

findLetters 2

May 27th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char userWords[101];
  8.     char letters[26];
  9.     int numbers[26];
  10.  
  11.     int i,symbolNum, letterNum, masNum, wordEnd;
  12.     char arra;
  13.     symbolNum=101;
  14.     cout << "enter symbols(words)(limit 30 symbols)" << endl;
  15.  
  16.     cin.getline(userWords,101);
  17.  
  18.     cout << "these symbols are taking part in the test now" << endl;
  19.     cout << userWords << endl;
  20.  
  21.     int symbol=0;
  22.  
  23.     for ( i=0; i<26;i++){
  24.         numbers[i]=0;
  25.         letters[i]=0;
  26.     } //обнуляет массивы
  27.  
  28.  
  29.  
  30.     for ( i = 0;i < symbolNum;i++ ){
  31.          if(userWords[symbol] >= 'a' && userWords[symbol] <= 'z'){
  32.  
  33.             userWords[symbol]=(int)userWords[symbol]-32;
  34.  
  35.          }
  36.          symbol++;
  37.     }  //делает буквы большими
  38.  
  39.    for( i = 0 ; i < symbolNum; i++){
  40.  
  41.              symbol = i;
  42.  
  43.             if((userWords[symbol] >= 'A' && userWords[symbol] <= 'Z') ){
  44.  
  45.                 if((userWords[symbol+1] >= 'A' && userWords[symbol+1] <= 'Z') || (userWords[symbol+1] >= 'a' && userWords[symbol+1] <= 'z') || (userWords[symbol+1] == '-')){
  46.                 continue;
  47.                 }else {
  48.                 wordEnd=symbol+1;
  49.                 }
  50.  
  51.                 cout << endl;
  52.                 cout << "end" << i+1;
  53.  
  54.  
  55.             }
  56.     }// ищет конец слова
  57.  
  58.     letterNum=0;
  59.     masNum=1;
  60.     while(letterNum <= wordEnd){
  61.        if(!(userWords[letterNum]==letters[masNum])) {
  62.             masNum++;
  63.             letters[masNum]=userWords[letterNum];
  64.        }
  65.        letterNum++;
  66.     }  //записует буквы в массив
  67.  
  68.     i =  1;
  69.     while(i<=masNum){
  70.         if(letters[i-1]<letters[i]){
  71.            arra=letters[i-1];
  72.            letters[i-1] = letters[i];
  73.            letters[i]=arra;
  74.            i=0;
  75.         }
  76.         i++;
  77.     } // сортировка
  78.  
  79.     for(i=0;i<masNum;i++){
  80.       for(int j=0;j<wordEnd;j++){
  81.         if(letters[i]==userWords[j]){
  82.             numbers[i]++;
  83.         }
  84.       }
  85.     } // ищет количество одинаковх букв в строке
  86.  
  87.     cout << endl << "-- -- -- -- -- -- -- -- --";
  88.     for(i=0;i<masNum;i++){
  89.         cout << endl << letters[i] + " - " + numbers[i];
  90.     }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement