laci200270

02.15 9/B első csoport javított

Feb 21st, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HetNapjai
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("A hét napjai");
  14.             int eddigiek = 0;
  15.             int mostaniszam=-1;
  16.             int elozoSzam = -1;
  17.            
  18.             while (mostaniszam != 0) {
  19.                 Console.ResetColor();
  20.                 Console.Write("Kérek egy számot 0 tól 7 ig: ");
  21.                 elozoSzam = mostaniszam;
  22.                 mostaniszam = int.Parse(Console.ReadLine());
  23.                 while (mostaniszam > 7 || mostaniszam < 0) {
  24.                     Console.Write("Hibás bemenet kérlek add meg újra");
  25.                    
  26.                     mostaniszam = int.Parse(Console.ReadLine());
  27.  
  28.                 }
  29.                 if (mostaniszam != 0)
  30.                     eddigiek++;
  31.                 if (elozoSzam == -1)
  32.                     Console.ResetColor();
  33.                 else
  34.                 {
  35.                     if (elozoSzam < mostaniszam)
  36.                         Console.ForegroundColor = ConsoleColor.Blue;
  37.                     else
  38.                         Console.ForegroundColor = ConsoleColor.Red;
  39.                 }
  40.                 switch(mostaniszam){
  41.                     case 1:
  42.                         Console.WriteLine("Hétfő");
  43.                         break;
  44.                     case 2:
  45.                         Console.WriteLine("Kedd");
  46.                         break;
  47.                     case 3:
  48.                         Console.WriteLine("Szerda");
  49.                         break;
  50.                     case 4:
  51.                         Console.WriteLine("Csütörtök");
  52.                         break;
  53.                     case 5:
  54.                         Console.WriteLine("Péntek");
  55.                         break;
  56.                     case 6:
  57.                         Console.WriteLine("Szombat");
  58.                         break;
  59.                     case 7:
  60.                         Console.WriteLine("Vasárnap");
  61.                         break;
  62.                     case 0:
  63.                         Console.ResetColor();
  64.                         Console.WriteLine("Összesen {0} darab napot írtunk ki.",eddigiek);
  65.                         Console.ReadKey();
  66.                         break;
  67.                 }
  68.                
  69.             }
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment