Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Aula_22_10_2014
- {
- class Program
- {
- static int Ano_Bissexto(int x)
- {
- if (x % 4 == 0 && x % 100 != 0)
- {
- x = 1;
- return x;
- }
- else
- {
- if (x % 400 == 0)
- {
- x = 1;
- return x;
- }
- else
- {
- x = 0;
- return x;
- }
- }
- }
- static int Calculadora_Dias( int diax, int mes, int ano)
- {
- int[] dia_meses = new int [13];
- dia_meses[1] = 31;
- dia_meses[2] = 28 + Ano_Bissexto(ano);
- dia_meses[3] = 31;
- dia_meses[4] = 30;
- dia_meses[5] = 31;
- dia_meses[6] = 30;
- dia_meses[7] = 31;
- dia_meses[8] = 31;
- dia_meses[9] = 30;
- dia_meses[10] = 31;
- dia_meses[11] = 30;
- dia_meses[12] = 31;
- for (int i = 1; i <= mes; i++)
- {
- diax = diax + dia_meses[i];
- }
- return diax-dia_meses[mes];
- }
- static void Main(string[] args)
- {
- int repetir = 1;
- do
- {
- int dia = 0, mes = 0, ano = 0, dias = 0;
- Console.Write("Digite o dia: ");
- dia = Int16.Parse(Console.ReadLine());
- Console.Write("Digite o mês: ");
- mes = Int16.Parse(Console.ReadLine());
- Console.Write("Digite o ano: ");
- ano = Int16.Parse(Console.ReadLine());
- dias = Calculadora_Dias(dia, mes, ano);
- Console.WriteLine("\nData:\t{0}/{1}/{2}\nNúmero de dias:\t{3}", dia, mes, ano, dias);
- Console.WriteLine("\n\aFaltam {0} dias para o ano acabar!", (365 + Ano_Bissexto(ano)) - dias);
- Console.Write("\nDeseja tentar outra data? 1 para sim, 0 para não: ");
- repetir = Int16.Parse(Console.ReadLine());
- Console.Clear();
- } while (repetir == 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement