Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. 7
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<ctype.h>
  5. char s[109], t[109];
  6. int main()
  7. {
  8. printf("Nhap ho ten nguoi thu nhat:");
  9. gets(s);
  10. printf("Nhap ho ten nguoi thu hai:");
  11. gets(t);
  12. int m=strlen(s), n=strlen(t), i, j, ok=1;
  13. for(i=0, j=0;i<m||j<n;)
  14. {
  15. if(i<m&&s[i]==' ')
  16. {
  17. i++;
  18. continue;
  19. }
  20. if(j<n&&t[j]==' ')
  21. {
  22. j++;
  23. continue;
  24. }
  25. if(tolower(s[i])==tolower(t[j]))
  26. {
  27. i++;
  28. j++;
  29. }
  30. else
  31. {
  32. ok=0;
  33. break;
  34. }
  35. }
  36. if(ok)
  37. {
  38. printf("2 ho ten giong nhau");
  39. }
  40. else
  41. {
  42. printf("2 ho ten khac nhau");
  43. }
  44. }
  45.  
  46. 5
  47. #include<stdio.h>
  48. #include<string.h>
  49. #include<ctype.h>
  50. char s[109];
  51. int i, l;
  52. int main()
  53. {
  54. printf("Nhap chuoi muon chuyen sang HOA: ");
  55. gets(s);
  56. l=strlen(s);
  57. printf("Chuoi hoa: ");
  58. for(i=0;i<l;i++)
  59. {
  60. printf("%c", toupper(s[i]));
  61. }
  62. printf("\n");
  63. fflush(stdin);
  64. printf("Nhap chuoi muon chuyen sang thuong: ");
  65. gets(s);
  66. l=strlen(s);
  67. printf("Chuoi thuong: ");
  68. for(i=0;i<l;i++)
  69. {
  70. printf("%c", tolower(s[i]));
  71. }
  72. }
  73.  
  74. 3
  75. #include<stdio.h>
  76. #include<string.h>
  77. char s[109];
  78. int main()
  79. {
  80. printf("Nhap vao mot chuoi: ");
  81. gets(s);
  82. int i, l=strlen(s);
  83. for(i=0;i<l/2;i++)
  84. {
  85. char c=s[i];
  86. s[i]=s[l-i-1];
  87. s[l-i-1]=c;
  88. }
  89. printf("Chuoi dao nguoc: ");
  90. puts(s);
  91. }
  92.  
  93. 1
  94. #include<stdio.h>
  95. #include<string.h>
  96. char s[109];
  97. int main()
  98. {
  99. gets(s);
  100. int i, l=strlen(s);
  101. for(i=0;i<l/2;i++)
  102. {
  103. char c=s[i];
  104. s[i]=s[l-i-1];
  105. s[l-i-1]=c;
  106. }
  107. puts(s);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement