Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- char userWords[101];
- char letters[26];
- int numbers[26];
- int i,symbolNum, letterNum, masNum, wordEnd;
- char arra;
- symbolNum=101;
- cout << "enter symbols(words)(limit 30 symbols)" << endl;
- cin.getline(userWords,101);
- cout << "these symbols are taking part in the test now" << endl;
- cout << userWords << endl;
- int symbol=0;
- for ( i=0; i<26;i++){
- numbers[i]=0;
- letters[i]=0;
- } //обнуляет массивы
- for ( i = 0;i < symbolNum;i++ ){
- if(userWords[symbol] >= 'a' && userWords[symbol] <= 'z'){
- userWords[symbol]=(int)userWords[symbol]-32;
- }
- symbol++;
- } //делает буквы большими
- for( i = 0 ; i < symbolNum; i++){
- symbol = i;
- if((userWords[symbol] >= 'A' && userWords[symbol] <= 'Z') ){
- if((userWords[symbol+1] >= 'A' && userWords[symbol+1] <= 'Z') || (userWords[symbol+1] >= 'a' && userWords[symbol+1] <= 'z') || (userWords[symbol+1] == '-')){
- continue;
- }else {
- wordEnd=symbol+1;
- }
- cout << endl;
- cout << "end" << i+1;
- }
- }// ищет конец слова
- letterNum=0;
- masNum=1;
- while(letterNum <= wordEnd){
- if(!(userWords[letterNum]==letters[masNum])) {
- masNum++;
- letters[masNum]=userWords[letterNum];
- }
- letterNum++;
- } //записует буквы в массив
- i = 1;
- while(i<=masNum){
- if(letters[i-1]<letters[i]){
- arra=letters[i-1];
- letters[i-1] = letters[i];
- letters[i]=arra;
- i=0;
- }
- i++;
- } // сортировка
- for(i=0;i<masNum;i++){
- for(int j=0;j<wordEnd;j++){
- if(letters[i]==userWords[j]){
- numbers[i]++;
- }
- }
- } // ищет количество одинаковх букв в строке
- cout << endl << "-- -- -- -- -- -- -- -- --";
- for(i=0;i<masNum;i++){
- cout << endl << letters[i] + " - " + numbers[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement