Tuesday, January 21, 2020

Codeforces 112A Petya and Strings Solution in C



  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. int x, i,o,l;
  6. x=0;
  7. char a[200],b[200];
  8. scanf("%s %s",&a,&b);
  9. l=strlen(a);
  10. for (i=0;i<l;i++)
  11. {
  12. o=a[i]-b[i];
  13. if (o!=0 && o!=32 && o!=-32)
  14. {
  15. if (a[i]<='z' && b[i]<='z' && a[i]>='a' && b[i]>='a')
  16. {
  17. if (a[i]>b[i])
  18. {
  19. x=1;
  20. break;
  21. }
  22. else
  23. {
  24. x=-1;
  25. break;
  26. }
  27. }
  28. if (a[i]<='Z' && b[i]<='Z' && a[i]>='A' && b[i]>='A')
  29. {
  30. if (a[i]>b[i])
  31. {
  32. x=1;
  33. break;
  34. }
  35. else
  36. {
  37. x=-1;
  38. break;
  39. }
  40. }
  41. if (a[i]<='Z' && a[i]>='A' && b[i]<='z' && b[i]>='a')
  42. {
  43. if (a[i]+32>b[i])
  44. {
  45. x=1;
  46. break;
  47. }
  48. else
  49. {
  50. x=-1;
  51. break;
  52. }
  53. }
  54. if (a[i]<='z' && a[i]>='a' && b[i]<='Z' && b[i]>='A')
  55. {
  56. if (a[i]-32>b[i])
  57. {
  58. x=1;
  59. break;
  60. }
  61. else
  62. {
  63. x=-1;
  64. break;
  65. }
  66. }
  67. }
  68. }
  69. printf("%d\n",x);
  70. return 0;
  71. }

No comments:

Post a Comment

Codeforces 131A cAPS lOCK Solution in C

#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...