Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Created February 18, 2015 11:59
Show Gist options
  • Save samueltcsantos/b15eaae8dde4dff47fe6 to your computer and use it in GitHub Desktop.
Save samueltcsantos/b15eaae8dde4dff47fe6 to your computer and use it in GitHub Desktop.
Algoritmo para verificar se o ano é bissexto.
algoritmo "bissexto"
// Função : Bissexto - Um ano é bissexto se ele for divisível por 400 ou se ele
// for divisível por 4 e não por 100.
// Bissexto: 1980, 1984, 1988, 1992, 1996 e 2000.
// 1900 não foi bissexto, mas 1600 foi
// Autor : Samuel T. C. Santos
// Data : 18/02/2015
// Seção de Declarações
var
ano : inteiro
inicio
// Seção de Comandos
escreva("Ano? ")
leia(ano)
se (ano mod 400 = 0) ou ((ano mod 4 = 0) e (ano mod 100 <> 0)) entao
escreval(ano, " é bisexto!")
fimse
fimalgoritmo
@vit0ur
Copy link

vit0ur commented Apr 10, 2023

Em C# esbocei três soluções possiveis aí fica a sua escolha qual utilizar

namespace Bissexto{
class ProgramBissexto{
static void Main(string[] args){

        Console.WriteLine("Digite o ano que deseja verificar se é bissexto: ");
        var ano = "";
        ano = Console.ReadLine();

/*SOLUÇÃO SECUNDARIA
if(Convert.ToInt32(ano)%4 == 0 && Convert.ToInt32(ano)%100 != 0 || Convert.ToInt32(ano)%400 == 0){
Console.WriteLine("O ano de "+ano+ " é bissexto");
}else{
Console.WriteLine("O ano de "+ano+" não é bissexto");
}
SOLUÇÃO TERCIARIA
if(DateTime.IsLeapYear(Convert.ToInt32(ano))){
Console.WriteLine("O ano informado é bissexto");
}
else{
Console.WriteLine("O ano informado NÃO é bissexto");
}
*/
switch ( Convert.ToInt32(ano) % 4 == 0 && Convert.ToInt32(ano) % 100 != 0 || Convert.ToInt32(ano) % 400 == 0 ) {
case (true):
Console.WriteLine(ano+" é bissexto");
break;
case (false):
Console.WriteLine(ano+" não é bissexto");
break;
}
}
}
}

@letxiz
Copy link

letxiz commented Aug 3, 2023

Olá

Tenho uma duvida

Como é feito no portugol o algoritmo referente ao ano bissexto????

@proccedure-caze
Copy link

proccedure-caze commented Aug 8, 2023

Olá

Tenho uma duvida

Como é feito no portugol o algoritmo referente ao ano bissexto????

// PORTUGOL

`
algoritmo "AnoBissexto"
var
ano: inteiro
inicio
escreva("Insira o ano que deseja verificar: ")
leia(ano)

se (ano mod 4 = 0) e ((ano mod 100 <> 0) ou (ano mod 400 = 0)) entao
escreva("O ano ", ano, " é bissexto.")
senao
escreva("O ano ", ano, " não é bissexto.")
fimse
fimalgoritmo
`

@zacarias19joel
Copy link

muito bem!

@Rogersorge
Copy link

Em Visual Basic:

Função Bissexto(Ano) Bissexto = Ano Mod 4 = 0 E Ano Mod 100 > 0 Ou Ano Mod 400 = 0 Função Final

Retorna true se ano for bissexto

@SuRochaa
Copy link

SuRochaa commented Jun 27, 2024

Eu fiz assim no Python 3.12.4:

Ano = int(input('Digite um ano: '))

Bissexto = Ano%4 == 0

if Bissexto:
print ('O ano é bissexto: ')
else:
print ('O ano não é bissexto: ')

@AndreOn04
Copy link

Fiz para determinar se um determinado ano é bissexto em DART.

import 'dart:math';

class Leap {
  bool leapYear(int year) {
    bool status = false;
    if (year % 4 == 0) {
      if (year % 100 == 0) {
        if ( year % 400 == 0 ) {
          status = true;
        } else {
          status = false;
        }
      } else {
        status = true;
      }
    } else {
      status = false;
    }
    return status;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment