Advertisement
FoguinhoS

Untitled

Oct 28th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. main()
  5. {
  6. int j, n1, n2, v;
  7. char c1, c2, N[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ", n[27]="abcdefghijklmnopqrstuvwxyz";
  8. printf("Escreva as duas letras, em ordem alfabetica:\n");
  9. scanf("%c %c", &c1, &c2);
  10. for (j=0;j<26;j++)
  11. {
  12. if(c1==N[j])
  13. {
  14. n1=j;
  15. }
  16. if(c2==N[j])
  17. {
  18. n2=j;
  19. }
  20. if(c1==n[j])
  21. {
  22. n1=j;
  23. }
  24. if(c2==n[j])
  25. {
  26. n2=j;
  27. }
  28. while(n1>n2)
  29. {
  30. printf("\nOs caracteres estao fora de ordem por favor arrume-os");
  31. printf("\nEscreva as duas letras, em ordem alfabetica:\n");
  32.  
  33. fflush(stdin);
  34. scanf("%c",&c1);
  35. fflush(stdin);
  36. scanf("%c",&c2);
  37. for (j=0;j<26;j++)
  38. {
  39. if(c1==N[j])
  40. {
  41. n1=j;
  42. }
  43. if(c2==N[j])
  44. {
  45. n2=j;
  46. }
  47. if(c1==n[j])
  48. {
  49. n1=j;
  50. }
  51. if(c2==n[j])
  52. {
  53. n2=j;
  54. }
  55. }
  56. }
  57. }
  58. v=(n2-n1)-1;
  59. printf("\nExistem %d letras entre %c e %c", v,c1, c2);
  60. getch();
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement