Advertisement
artur99

Untitled

Aug 1st, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cstring>
  4. using namespace std;
  5. ifstream fin("cifre006.in");
  6. ofstream fout("cifre006.out");
  7. int main()
  8. {
  9.     char s[20];
  10.     int k, i, l, ap = 0;
  11.     fin>>s;
  12.     fin>>k;
  13.    
  14.     l = strlen(s);
  15.     for(i = 0; i < l; i++)
  16.         if(s[i] - '0' == k) ap++;
  17.     fout<<ap<<'\n';
  18.    
  19.     for(i = 0; i < ap; i++)
  20.         fout<<(char)('0' + k);
  21.    
  22.     for(i = 0; i < l; i++)
  23.         if(s[i] - '0' != k) fout<<s[i];
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement