Advertisement
Metts

Pitypang - Emelt informatika érettségi

Apr 5th, 2012
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace Pitypang
  8. {
  9.     //Coded by Metts / metts.blog.hu
  10.     class foglalas
  11.     {
  12.         public int id;
  13.         public int szoba_szam;
  14.         public int erkezes_napja_id;
  15.         public int tavozas_napja_id;
  16.         public int vendegek_szam;
  17.         public int reggeli;
  18.         public string nev;
  19.  
  20.         public foglalas(string[] dat)
  21.         {
  22.             id               = int.Parse(dat[0]);
  23.             szoba_szam       = int.Parse(dat[1]);
  24.             erkezes_napja_id = int.Parse(dat[2]);
  25.             tavozas_napja_id = int.Parse(dat[3]);
  26.             vendegek_szam    = int.Parse(dat[4]);
  27.             reggeli          = int.Parse(dat[5]);
  28.             nev              = dat[6];
  29.         }
  30.  
  31.         public int ar()
  32.         {
  33.             int ar          = 0;
  34.             int toltott_ido = tavozas_napja_id - erkezes_napja_id;
  35.             int reggeli_ossz= 0;
  36.             int potagy      = 0;
  37.             int honapok     = 0;
  38.             int szorzo      = 0;
  39.  
  40.             if (erkezes_napja_id < 121) //TAVASZ
  41.                 szorzo = 9000;
  42.             else if (erkezes_napja_id >= 121 && erkezes_napja_id < 244) //NYÁR
  43.                 szorzo = 10000;
  44.             else if (erkezes_napja_id >= 244) //ŐSZ
  45.                 szorzo = 8000;
  46.  
  47.             honapok = toltott_ido * szorzo;
  48.  
  49.             if (reggeli == 1)
  50.                 reggeli_ossz = (toltott_ido * vendegek_szam) * 1100;
  51.            
  52.             if (vendegek_szam > 2)
  53.                 potagy = (vendegek_szam - 2) * (toltott_ido * 2000);
  54.             ar = honapok + reggeli_ossz + potagy;
  55.  
  56.             return ar;
  57.         }
  58.  
  59.     }
  60.  
  61.     class honapok
  62.     {
  63.         public string nev;
  64.         public string nap_szam;
  65.         public string end;
  66.         public int vendegek_szama = 0;
  67.  
  68.         public honapok(string n, string szam1, string szam2)
  69.         {
  70.             nev         = n;
  71.             nap_szam = szam1;
  72.             end = szam2;
  73.         }
  74.     }
  75.  
  76.     class Program
  77.     {
  78.         static void Main(string[] args)
  79.         {
  80.             #region 1.Feladat
  81.                 List<foglalas> foglal = new List<foglalas>();
  82.                 StreamReader sr = new StreamReader("../../pitypang.txt");
  83.                 int end = int.Parse(sr.ReadLine());
  84.                 for (int i = 0; i < end; i++)
  85.                 {
  86.                     string[] split             = sr.ReadLine().Split(' ');
  87.                     foglal.Add(new foglalas(split));
  88.                 }
  89.             #endregion
  90.  
  91.             #region 2.Feladat
  92.                 int max = 0;
  93.                 int id = 0;
  94.                 for (int i = 0; i < end; i++)
  95.                 {
  96.                     int hossz = foglal[i].tavozas_napja_id - foglal[i].erkezes_napja_id;
  97.  
  98.                     if (hossz > max)
  99.                     {
  100.                         max = hossz;
  101.                         id = i;
  102.                     }
  103.                 }
  104.                 Console.WriteLine("II. Feladat. Leghoszabb szállodai tartózkodás:\n {0} ({1}) -  {2}", foglal[id].nev, foglal[id].erkezes_napja_id, max);
  105.             #endregion
  106.  
  107.             #region 3.Feladat
  108.                 StreamWriter writer = new StreamWriter("../../bevetel.txt");
  109.                 for (int i = 0; i < end; i++)
  110.                     writer.WriteLine(foglal[i].id + ":" + foglal[i].ar());
  111.                 writer.Close();
  112.             #endregion
  113.            
  114.             #region 4.Feladat
  115.                 List<honapok> honapok = new List<honapok>();
  116.                 StreamReader sr2 = new StreamReader("../../honapok.txt");
  117.                 for (int i = 0; i < end; i++)
  118.                 {
  119.                     if (foglal[i].vendegek_szam == 1)
  120.                     {
  121.                         //if ((foglal[i].tavozas_napja_id - foglal[i].erkezes_napja_id) == 1)
  122.                            // Console.WriteLine(foglal[i].nev);
  123.                     }
  124.                 }
  125.             #endregion
  126.                      
  127.             Console.Read();
  128.  
  129.         }
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement