askarulytarlan

санта клаус и проверка клавиатуры

Dec 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. string s,a;
  10. int sum1 = 0, sum2 = 0;
  11. int ans = 0;
  12. int n = 0;
  13. char d[10000][2];
  14. cin >> a;
  15. cin >> s;
  16. bool k=0;
  17. for(int i = 0; i < a.size(); i++){
  18. for(int j = 0; j < i; j ++){
  19. if(a[i] == d[j][0] || a[i] == d[j][1] || s[i] == d[j][0] || s[i] == d[j][1]){
  20. k = 1;
  21. }
  22. if((s[i] == d[j][1] && a[i] != d[j][0]) || (s[i] != s[j] && a[i] == a[j]) || (a[i] != a[j] && s[i] == s[j]) || (s[i] != s[j] && a[i] == a[j])){
  23. cout << -1;
  24. return 0;
  25. }
  26. }
  27. if(a[i] != s[i] && k == 0){
  28. ans++;
  29. d[n][0] = s[i];
  30. d[n][1] = a[i];
  31. n++;
  32. }
  33. k = 0;
  34. }
  35. cout << n << endl;
  36. for(int i = 0; i < n; i++){
  37. cout << d[i][1] << " " << d[i][0] << endl;
  38. }
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment