From 0543d60f3f5eb241d08f936587561704209864f6 Mon Sep 17 00:00:00 2001 From: StarPlatinum_DevPBR <129001970+DevPBR@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:52:34 -0300 Subject: [PATCH] =?UTF-8?q?Se=20=C3=A8=20febbraio,=20il=20mese=20dovrebbe?= =?UTF-8?q?=20avere=2028=20giorni.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dare l'opzione per l'utente di selezionare se è il mese di febbraio, se sì, il mese avrà solo 28 giorni, in caso contrario, avrà 31. --- Calendario.cpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Calendario.cpp b/Calendario.cpp index b53b56e..6c8d1ea 100644 --- a/Calendario.cpp +++ b/Calendario.cpp @@ -3,14 +3,19 @@ main() { int scelta=7, counter, giorni; - + char feb; do{printf("Che giorno e' il primo del mese?"); printf("\n0) Lun\n1) Mar\n2) Mer\n3) Gio\n4) Ven\n5) Sab\n6) Dom"); printf("\nInserire la scelta: "); scanf("%d",&scelta); printf("\n\n");}while(scelta>6); counter=scelta; + printf("È febbraio?? 'S' per il sì 'N' per no \n"); + getchar(); + scanf("%c", &feb); + if(feb == 'S') + { printf("\n\n Lun Mar Mer Gio Ven Sab Dom\n"); while(scelta>0){ @@ -18,13 +23,33 @@ main() printf(" "); } + for(giorni = 1; giorni < 29; giorni++){ + printf("%4d",giorni); + if((giorni+counter)%7==0)printf("\n"); + } + + fflush(stdin); + + } + else if(feb == 'N') + { + printf("\n\n Lun Mar Mer Gio Ven Sab Dom\n"); + + while(scelta>0){ + scelta--; + printf(" "); + } + for(giorni = 1; giorni < 32; giorni++){ printf("%4d",giorni); if((giorni+counter)%7==0)printf("\n"); } -fflush(stdin); -getchar(); -return 0; + fflush(stdin); + } + else + { + printf("Failed"); + } + return(0); } -