Advertisement
kirya_shkolnik

Андрей - подсччерт символов

Jun 13th, 2021
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <string>
  11. using namespace std;
  12. string task(string str){
  13.         string newstr = "";
  14.         for(int i=0; i<str.length(); i++){
  15.         char symbol = str[i];
  16.         int count=1;
  17.         if(symbol !=' '){
  18.             for(int j=i+1;j<str.length(); j++){
  19.                 if(str[j] == symbol){
  20.                     str[j] = ' ';
  21.                     count++;
  22.                 }
  23.             }
  24.             cout<<count<<symbol; // Вместо вывода сделай сбор строки
  25.             //newstr+=count.toStrring() + symbol.toString();
  26.         }
  27.     }
  28.     return newstr;
  29. }
  30. int main()
  31. {
  32.     string str = "NANSANNS";
  33.     task(str);
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement