Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define TRUE 1
- int _Val(int Num, int LimitInf, int LimitSup);
- int _Toupper(char x);
- int main()
- {
- /// Declaracao e Iniciliazacao de variaveis.
- int Formato1, N1, N2, N3, N4, Formato2, count;
- int n1, n2, n3, n4, temp;
- char X1, X2, X3, X4, x2, x1;
- Formato1 = N1 = N2 = N3 = N4 = Formato2 = count = temp = x2 = n1 = n2 = x1 = 0;
- /////
- /// Input e Validacao da Matricula 1
- printf("Indique o Formato (M1): ");
- fflush(stdin);
- scanf("%d", &Formato1);
- // Escolha do tipo de Matricula
- printf("Introduza a Matricula (M1): ");
- fflush(stdin);
- switch(Formato1)
- {
- case 1: scanf("%c%c-%d-%d", &X1, &X2, &N1, &N2);;break;
- case 2: scanf("%d-%d-%c%c", &N1, &N2, &X1, &X2);break;
- case 3: scanf("%d-%c%c-%d", &N1, &X1, &X2, &N2);break;
- default: printf("\nErro\n"); return 0;
- }
- X1 = _Toupper(X1);
- X2 = _Toupper(X2);
- // Validacao
- if( !_Val(N1,0,99) || !_Val(N2,0,99) || !_Val(X1,'A','Z') || !_Val(X2,'A','Z') )
- {
- printf("\nErro\n");
- return 0;
- }
- /////
- /// Input e Validacao da Matricula 2
- printf("Indique o Formato (M2): ");
- fflush(stdin);
- scanf("%d", &Formato2);
- // Escolha da Matricula 2
- printf("Introduza a Matricula (M2): ");
- fflush(stdin);
- switch(Formato2)
- {
- case 1: scanf("%c%c-%d-%d", &X3, &X4, &N3, &N4);;break;
- case 2: scanf("%d-%d-%c%c", &N3, &N4, &X3, &X4);break;
- case 3: scanf("%d-%c%c-%d", &N3, &X3, &X4, &N4);break;
- default: printf("\nErro\n"); return 0;
- }
- X3 = _Toupper(X3);
- X4 = _Toupper(X4);
- // Validacao da Matricula 2
- if( !_Val(N3,0,99) || !_Val(N4,0,99) || !_Val(X3,'A','Z') || !_Val(X4,'A','Z') )
- {
- printf("\nErro\n");
- return 0;
- }
- /////
- for(x1 = X1; x1 <= X3 ; x1++)
- {
- for(x2 = 'A'; x2 < 'Z'+1 ; x2++)
- {
- if( temp == 0 )
- x2 == X2;
- for(n1 = 0; n1 <= 99 ; n1++)
- {
- if( temp == 0 )
- n1 == N1;
- for(n2 = 0; n2 <= 99 ; n2++)
- {
- if( temp == 0 )
- {
- temp++;
- n2 = N2;
- }
- if( n2 == N4 && n1 == N3 )
- break;
- }
- count += n2;
- if( n2 == N4 && n1 == N3 && x2 == X4)
- break;
- }
- if( n2 == N4 && n1 == N3 && x2 == X4 && x1 == X3)
- break;
- }
- }
- printf("\n %d \n", count);
- return 0;
- }
- int _Val(int Num, int LimitInf, int LimitSup)
- {
- return (Num >= LimitInf && Num <= LimitSup) ? 1 : 0;
- }
- int _Toupper(char x)
- {
- return (x >= 'a' && x <= 'z') ? x+32 : x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement