Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- main()
- {
- int j, n1, n2, v;
- char c1, c2, N[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ", n[27]="abcdefghijklmnopqrstuvwxyz";
- printf("Escreva as duas letras, em ordem alfabetica:\n");
- scanf("%c %c", &c1, &c2);
- for (j=0;j<26;j++)
- {
- if(c1==N[j])
- {
- n1=j;
- }
- if(c2==N[j])
- {
- n2=j;
- }
- if(c1==n[j])
- {
- n1=j;
- }
- if(c2==n[j])
- {
- n2=j;
- }
- while(n1>n2)
- {
- printf("\nOs caracteres estao fora de ordem por favor arrume-os");
- printf("\nEscreva as duas letras, em ordem alfabetica:\n");
- fflush(stdin);
- scanf("%c",&c1);
- fflush(stdin);
- scanf("%c",&c2);
- for (j=0;j<26;j++)
- {
- if(c1==N[j])
- {
- n1=j;
- }
- if(c2==N[j])
- {
- n2=j;
- }
- if(c1==n[j])
- {
- n1=j;
- }
- if(c2==n[j])
- {
- n2=j;
- }
- }
- }
- }
- v=(n2-n1)-1;
- printf("\nExistem %d letras entre %c e %c", v,c1, c2);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement