Notes
![]() ![]() Notes - notes.io |
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NEZOTER
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1. FELADAT");
var foglaltsag = File.ReadAllLines("foglaltsag.txt");
var kategoria = File.ReadAllLines("kategoria.txt");
Console.WriteLine("2. FELADAT");
{ // blokk, amiben független lokális változók vannak pl. sor/szék
Console.Write("Adja meg egy sor számát: ");
var sor = int.Parse(Console.ReadLine()) - 1;
Console.Write("Adja meg egy szék számát: ");
var szek = int.Parse(Console.ReadLine()) - 1;
if (foglaltsag[sor][szek] == 'x')
{
Console.WriteLine("Az adott hely foglalt!");
}
else
{
Console.WriteLine("Az adott hely szabad!");
}
} // blokk vége
Console.WriteLine("3. FELADAT");
var foglalt = 0;
foreach (var sor in foglaltsag)
{
foreach (var szek in sor)
{
if (szek == 'x')
{
foglalt++;
}
}
}
var szazalek = foglalt * 100.0 / (15 * 20);
var kerekitve = Convert.ToInt32(Math.Round(szazalek));
Console.WriteLine("Az előadásra eddig {0} jegyet adtak el, az a nézőtér {1}%-a",
foglalt, kerekitve);
Console.WriteLine("4. FELADAT");
var katfog = new int[6]; // 0. nem, 1..5-ig kategória
for (int sor = 0; sor < foglaltsag.Length; sor++)
{
for (int szek = 0; szek < foglaltsag[sor].Length; szek++)
{
if (foglaltsag[sor][szek] == 'x')
{
//var kat = Convert.ToByte(kategoria[sor][szek] - '0');
var kat = Convert.ToInt32(new string(kategoria[sor][szek], 1));
katfog[kat]++;
}
}
}
int max = 0;
int maxkat = 0;
for (int i = 1; i <= 5; i++)
{
if (katfog[i]>max)
{
max = katfog[i];
maxkat = i;
}
}
Console.WriteLine("A legtöbb jegyet a(z) {0}. kategóriában értékesítették.", maxkat);
Console.WriteLine("5. FELADAT");
var forint = new int[] { 0, 5000, 4000, 3000, 2000, 1500 };
var osszesen = 0;
for (int i = 1; i <= 5; i++)
{
osszesen += forint[i] * katfog[i];
}
Console.WriteLine("Jelenlegi bevétel: {0},-Ft", osszesen);
Console.WriteLine("6. FELADAT");
var egyedulallo = 0;
foreach (var sor in foglaltsag)
{
var bovitett = "x" + sor + "x";
for (int i = 1; i < bovitett.Length - 1; i++)
{
if (bovitett[i] == 'o'
&& bovitett[i-1]=='x'
&& bovitett[i + 1] == 'x')
{
egyedulallo++;
}
}
}
Console.WriteLine("Egyedülálló székek száma: {0}", egyedulallo);
Console.WriteLine("7. FELADAT");
using (var kiir = File.CreateText("szabad.txt")) // Console.Out
{
for (int i = 0; i < foglaltsag.Length; i++)
{
for (int j = 0; j < foglaltsag[i].Length; j++)
{
if (foglaltsag[i][j] == 'x')
{
kiir.Write('x');
}
else
{
kiir.Write(kategoria[i][j]);
}
}
kiir.WriteLine();
}
}
Console.ReadLine();
}
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team