Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <string>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <iomanip>
  6. #include <fstream>
  7. #include <deque>
  8. #include <vector>
  9. #include <utility>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.  
  16. ifstream in("input.txt");
  17. ofstream out("output.txt");
  18.  
  19. char masa[100][100];
  20. char masb[100][100];
  21.  
  22. int n, m,count = 0;
  23. in >> n >> m;
  24. string s1,s2;
  25.  
  26. for (int i = 0; i < n; i++) {
  27. for (int j = 0; j < m; j++) {
  28. in >> masa[i][j];
  29. }
  30. }
  31.  
  32. for (int i = 0; i < n; i++) {
  33. for (int j = 0; j < m; j++) {
  34. in >> masb[i][j];
  35. }
  36. }
  37.  
  38.  
  39.  
  40. for (int i = 0; i < n; i++) {
  41. for (int j = 0; j < m; j++) {
  42. if (masa[i][j] != '.') {
  43. if (masa[i][j] != masb[i][j]) {
  44. count++;
  45. if (islower(masa[i][j])) {
  46. s2.push_back(masa[i][j]);
  47. }
  48. else {
  49. s1.push_back(masa[i][j]);
  50. }
  51. }
  52. }
  53. }
  54. }
  55.  
  56.  
  57. out << count << endl;
  58. sort(s1.begin(), s1.end());
  59. sort(s2.begin(), s2.end());
  60. out << s2 << s1;
  61.  
  62. out.close();
  63. in.close();
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement