Advertisement
FoguinhoS

Untitled

Oct 28th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4.  
  5. // A vida é azul e amarela igual os caracois da china
  6. main()
  7. {
  8. int j, n1, n2, v;
  9. char c1, c2, N[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ", n[27]="abcdefghijklmnopqrstuvwxyz";
  10. printf("Escreva as duas letras, em ordem alfabetica:\n");
  11. scanf("%c %c", &c1, &c2);
  12. for (j=0;j<26;j++)
  13. {
  14. if(c1==N[j])
  15. {
  16. n1=j;
  17. }
  18. if(c2==N[j])
  19. {
  20. n2=j;
  21. }
  22. if(c1==n[j])
  23. {
  24. n1=j;
  25. }
  26. if(c2==n[j])
  27. {
  28. n2=j;
  29. }
  30. while(n1>n2)
  31. {
  32. printf("\nOs caracteres estao fora de ordem por favor arrume-os");
  33. printf("\nEscreva as duas letras, em ordem alfabetica:\n");
  34.  
  35. fflush(stdin);
  36. scanf("%c %c",&c1,&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