diegomaldaner
(usa Slackware)
Enviado em 25/06/2009 - 20:31h
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
char* TraduzData(int pDia, int pMes)
{
char DataExtensa[255];
char day[255];
char month[255];
switch (pDia)
{
case 1 : strcpy(day, "Um"); break;
case 2 : strcpy(day, "Dois"); break;
case 3 : strcpy(day, "Tres"); break;
case 4 : strcpy(day, "Quatro"); break;
case 5 : strcpy(day, "Cinco"); break;
case 6 : strcpy(day, "Seis"); break;
case 7 : strcpy(day, "Sete"); break;
case 8 : strcpy(day, "Oito"); break;
case 9 : strcpy(day, "Nove"); break;
case 10 : strcpy(day, "Dez"); break;
case 11 : strcpy(day, "Onze"); break;
case 12 : strcpy(day, "Doze"); break;
case 13 : strcpy(day, "Treze"); break;
case 14 : strcpy(day, "Quatorze"); break;
case 15 : strcpy(day, "Quinze"); break;
case 16 : strcpy(day, "Dezesseis"); break;
case 17 : strcpy(day, "Dezessete"); break;
case 18 : strcpy(day, "Dezoito"); break;
case 19 : strcpy(day, "Dezenove"); break;
case 20 : strcpy(day, "Vinte"); break;
case 21 : strcpy(day, "Vinte e Um"); break;
case 22 : strcpy(day, "Vinte e Dois"); break;
case 23 : strcpy(day, "Vinte e Tres"); break;
case 24 : strcpy(day, "Vinte e Quatro"); break;
case 25 : strcpy(day, "Vinte e Cinco"); break;
case 26 : strcpy(day, "Vinte e Seis"); break;
case 27 : strcpy(day, "Vinte e Sete"); break;
case 28 : strcpy(day, "Vinte e Oito"); break;
case 29 : strcpy(day, "Vinte e Nove"); break;
case 30 : strcpy(day, "Trinta"); break;
case 31 : strcpy(day, "Trinta e Um"); break;
default : strcpy(day, "Dia Invalido");
}
switch (pMes)
{
case 1 : strcpy(month, "Janeiro"); break;
case 2 : strcpy(month, "Fevereiro"); break;
case 3 : strcpy(month, "Marco"); break;
case 4 : strcpy(month, "Abril"); break;
case 5 : strcpy(month, "Maio"); break;
case 6 : strcpy(month, "Junho"); break;
case 7 : strcpy(month, "Julho"); break;
case 8 : strcpy(month, "Agosto"); break;
case 9 : strcpy(month, "Setembro"); break;
case 10 : strcpy(month, "Outubro"); break;
case 11 : strcpy(month, "Novembro"); break;
case 12 : strcpy(month, "Dezembro"); break;
default : strcpy(month, "Mes Invalido");
}
strcat(DataExtensa, day);
strcat(DataExtensa, " de ");
strcat(DataExtensa, month);
strcat(DataExtensa, ".");
return DataExtensa;
}
main()
{
////////////////////////////////////////////////////////////////////////////////////////// clscr();
char A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int dia = 0;
int mes = 0;
int index = 0;
int indexes = 0;
while (indexes != 10)
{
while (index != 1)
{
printf("\nDigite o dia: ");
scanf("%d", &dia);
printf("\nDigite o mes: ");
scanf("%d", &mes);
if ((dia > 0 && dia < 32) && (mes > 0 && mes < 12))
{
index = 1;
indexes++;
if (indexes == 1)
{
strcpy(A[0], TraduzData(dia, mes));
}
switch (indexes)
{
case 1 : strcpy(A[0], TraduzData(dia, mes));
case 2 : strcpy(A[1], TraduzData(dia, mes));
case 3 : strcpy(A[2], TraduzData(dia, mes));
case 4 : strcpy(A[3], TraduzData(dia, mes));
case 5 : strcpy(A[4], TraduzData(dia, mes));
case 6 : strcpy(A[5], TraduzData(dia, mes));
case 7 : strcpy(A[6], TraduzData(dia, mes));
case 8 : strcpy(A[7], TraduzData(dia, mes));
case 9 : strcpy(A[8], TraduzData(dia, mes));
case 10 : strcpy(A[9], TraduzData(dia, mes));
}
}
else
{
printf("\nData Invalida.");
}
}
index = 0;
}
printf("%s",A[0]);
printf("%s",A[1]);
printf("%s",A[2]);
printf("%s",A[3]);
printf("%s",A[4]);
printf("%s",A[5]);
printf("%s",A[6]);
printf("%s",A[7]);
printf("%s",A[8]);
printf("%s",A[9]);
printf("Press Any Key...");
getch();
}