Advertisement
Guest User

1

a guest
Jun 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <iostream>
  3. #include <ctime>
  4. const long long N = 101;
  5. const int ALL = 25;
  6.  
  7. char* generateStr(int size) {
  8. srand(time(NULL));
  9. int number;
  10. char str[N] = { };
  11. char a[52] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
  12. for (int i = 0; i <= size; i++) {
  13. number = rand() % 7;
  14. if (number == rand() % 7) {
  15. str[i].insert(i, " ");
  16. }
  17. str[i] += a[rand() % 52];
  18.  
  19. }
  20. return str;
  21.  
  22. }
  23.  
  24. int main() {
  25. int num;
  26. bool flag = false;
  27. int i = 0;
  28. char a[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
  29. char b[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
  30. char str[N];
  31. generateStr(ALL);
  32. fgets(str, 101, stdin);
  33. while (str[i] != '\n') {
  34. if (isupper(str[i])) {
  35. for (int j = 0; j <= ALL; j++) {
  36. if (str[i] == b[j]) {
  37. num = ALL - j;
  38. flag = true;
  39. printf("%c", b[num]);
  40. break;
  41. } else {
  42. flag = false;
  43. }
  44. }
  45. if (!flag) {
  46. printf("%c", str[i]);
  47. }
  48. } else {
  49. for (int j = 0; j <= ALL; j++) {
  50. if (str[i] == a[j]) {
  51. num = ALL - j;
  52. flag = true;
  53. printf("%c", a[num]);
  54. break;
  55. } else {
  56. flag = false;
  57. }
  58. }
  59. if (!flag) {
  60. printf("%c", str[i]);
  61. }
  62. }
  63. i++;
  64. }
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement