Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace Hernyák_jegyzetei
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Console.Clear();
- Console.WriteLine("1. Hello Pityuka!");
- Console.WriteLine("2. számok 1-től 10-ig");
- Console.WriteLine("3. páros számok 1-től 10-ig");
- Console.WriteLine("4. tetszőleges mennyiségű számok 1-től 10-ig");
- Console.WriteLine("5. 1..100 közötti számok összege");
- Console.WriteLine("6. számtani sorozat");
- Console.WriteLine("7. fibonacci sorozat");
- Console.WriteLine("8. osztók");
- Console.WriteLine("9. prímszámok 1000-ig");
- Console.WriteLine("10. rekurzív számsorozat");
- Console.WriteLine("11. Első n szám négyzete");
- Console.WriteLine("12. Prímtényezős felbontás");
- Console.WriteLine("13. Keringő csillag");
- Console.WriteLine("14. 10x10-es négyzet");
- Console.WriteLine("15. pattogó labda");
- Console.WriteLine("16. mértani sorozat");
- Console.WriteLine("17. adott szám első n hatványát");
- Console.WriteLine("18. első 100 páros szám");
- Console.WriteLine("19 1+4 számsorozat");
- Console.WriteLine("20. while amig space nem jön");
- Console.WriteLine("21. while amig nulla, összeg");
- int s = int.Parse(Console.ReadLine());
- switch (s)
- {
- case 1:
- {
- int a = 1;
- while (a <= 5)
- {
- Console.Write("Hello Pityuka! ");
- a++;
- }
- Console.ReadKey();
- break;
- }
- case 2:
- {
- int a = 1;
- while (a <= 10)
- {
- Console.Write("{0},", a);
- a++;
- }
- Console.ReadKey();
- break;
- }
- case 3:
- {
- int a = 2;
- while (a <= 10)
- {
- Console.Write("{0},", a);
- a += 2;
- }
- Console.ReadKey();
- break;
- }
- case 4:
- {
- Console.WriteLine("Írja be, hogy mennyi számot akar kiírni:");
- int m = int.Parse(Console.ReadLine());
- int a = 1;
- while (a <= m)
- {
- Console.Write("{0},", a);
- a++;
- }
- Console.ReadKey();
- break;
- }
- case 5:
- {
- int sum100 = 0;
- int i = 1;
- while (i <= 100)
- {
- sum100 += i;
- i++;
- }
- Console.Write(sum100);
- Console.ReadKey();
- break;
- }
- case 6:
- {
- Console.WriteLine("Számtani sorozat:");
- Console.WriteLine("Első elem?");
- long elem = int.Parse(Console.ReadLine());
- Console.WriteLine("differencia?");
- long differencia = int.Parse(Console.ReadLine());
- Console.WriteLine("elemszám?");
- int elemszam = int.Parse(Console.ReadLine());
- long osszeg = 0;
- Console.WriteLine(elem);
- for (int i = 1; i <= elemszam; i++)
- {
- elem = elem + differencia;
- Console.WriteLine(elem);
- osszeg = osszeg + elem;
- }
- Console.WriteLine();
- Console.WriteLine("Az elemek összege: {0}", osszeg);
- break;
- }
- case 7:
- int fibonacci1 = 0;
- int fibonacci2 = 1;
- int fibonacci3 = 0;
- int mennyi = 2;
- Console.WriteLine("1. Fibonacci szám: 0");
- while (mennyi < 30)
- {
- fibonacci3 = fibonacci1 + fibonacci2;
- Console.WriteLine("{0}. Fibonacci szám: {1}", mennyi + 1, fibonacci3);
- fibonacci1 = fibonacci2;
- fibonacci2 = fibonacci3;
- mennyi++;
- }
- break;
- case 8:
- Console.WriteLine("Adj meg egy számot!");
- int szam = int.Parse(Console.ReadLine());
- int i1 = 2;
- while (i1 <= szam / 2)
- {
- if (szam % i1 == 0)
- {
- Console.WriteLine(i1);
- }
- else
- {
- Console.WriteLine("Nincs osztója!");
- }
- i1++;
- }
- break;
- case 9:
- Console.WriteLine("Prímszámok 1000-ig.");
- for (int prim = 0; prim < 1000; prim++)
- {
- int db = 0;
- for (int oszto = 2; oszto < prim / 2; oszto++)
- {
- if (prim % oszto == 0)
- {
- db++;
- }
- }
- if (db == 0)
- {
- Console.WriteLine(prim);
- }
- }
- break;
- case 10:
- Console.WriteLine("Rekurzív számsorozat");
- int novekszik = 4;
- int a3 = 3;
- int plusz = 0;
- int a1 = a3;
- int a2 = a1 + novekszik;
- for (int i = 0; i < 20; i++)
- {
- if (i % 2 == 1)
- {
- plusz = (a2 + a1) / 2;
- Console.WriteLine(plusz);
- }
- if (i % 2 == 0)
- {
- plusz = (a2 - a1) * 2;
- Console.WriteLine(plusz);
- }
- a1 = a1 + novekszik;
- a2 = a2 + novekszik;
- }
- break;
- case 11:
- Console.WriteLine("n négyzetszám");
- Console.Write("n= ");
- int n = int.Parse(Console.ReadLine());
- for (int i = 1; i < n + 1; i++)
- {
- Console.WriteLine("{0}", i * i);
- }
- break;
- case 12:
- Console.WriteLine("3. FELADAT: Előállítja egy szám prímtényezős felbontását");
- Console.Write("A = ");
- int e3 = int.Parse(Console.ReadLine());
- Console.Write("{0} = ", e3);
- int e3bolmaradt = e3;
- for (int i3 = 2; i3 <= e3; )
- {
- if (e3bolmaradt % i3 == 0)
- {
- e3bolmaradt = e3bolmaradt / i3;
- if (e3bolmaradt == 1)
- {
- Console.Write("{0}", i3);
- }
- else
- {
- Console.Write("{0}*", i3);
- }
- }
- else
- {
- i3++;
- }
- }
- break;
- case 13:
- #region első for ciklus
- for (int i = 0; i < 10; i++)
- {
- Console.Clear();
- Console.SetCursorPosition(i, 0);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region második for ciklus
- for (int i = 0; i < 6; i++)
- {
- Console.Clear();
- Console.SetCursorPosition(10, i);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region harmadik for ciklus
- for (int i = 10; i > 0; i--)
- {
- Console.Clear();
- Console.SetCursorPosition(i, 6);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region negyedik for ciklus
- for (int i = 6; i > 0; i--)
- {
- Console.Clear();
- Console.SetCursorPosition(0, i);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- break;
- case 14:
- Console.Clear();
- #region első for ciklus
- for (int i = 0; i < 10; i++)
- {
- Console.SetCursorPosition(i, 0);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region második for ciklus
- for (int i = 0; i < 6; i++)
- {
- Console.SetCursorPosition(10, i);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region harmadik for ciklus
- for (int i = 10; i > 0; i--)
- {
- Console.SetCursorPosition(i, 6);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- #region negyedik for ciklus
- for (int i = 6; i > 0; i--)
- {
- Console.SetCursorPosition(0, i);
- Console.Write('*');
- Thread.Sleep(40);
- }
- #endregion
- break;
- case 15:
- int x = 0;
- int y = 10;
- string iranyv = "jobbra";
- string iranyf = "le";
- while (x < 80)
- {
- Console.SetCursorPosition(x, y);
- Console.WriteLine("*");
- System.Threading.Thread.Sleep(30);
- Console.SetCursorPosition(x, y);
- Console.Write(" ");
- //Vízszintes
- if (x >= 79)
- {
- iranyv = "balra";
- }
- if (x <= 0)
- {
- iranyv = "jobbra";
- }
- if (iranyv == "jobbra")
- {
- x = x + 1;
- }
- if (iranyv == "balra")
- {
- x = x - 1;
- }
- //Függőleges
- if (y >= 24)
- {
- iranyf = "fel";
- }
- if (y <= 0)
- {
- iranyf = "le";
- }
- if (iranyf == "le")
- {
- y = y + 1;
- }
- if (iranyf == "fel")
- {
- y = y - 1;
- }
- }
- break;
- case 16:
- Console.WriteLine("Mértani sorozat:");
- Console.WriteLine("Első elem?");
- long elem1 = int.Parse(Console.ReadLine());
- Console.WriteLine("Kvóciens?");
- long kvociens = int.Parse(Console.ReadLine());
- long osszeg1 = 0;
- Console.WriteLine(elem1);
- for (int i = 1; i <= 20; i++)
- {
- elem1 = elem1 * kvociens;
- Console.WriteLine(elem1);
- osszeg1 = osszeg1 + elem1;
- }
- Console.WriteLine();
- Console.WriteLine("Az elemek összege: {0}", osszeg1);
- break;
- case 17:
- Console.WriteLine("Adj meg egy számot, én kiírom első n db hatványát");
- Console.Write("A szám: ");
- int szam2 = int.Parse(Console.ReadLine());
- Console.Write("n: ");
- int ndb = int.Parse(Console.ReadLine());
- int eredmeny = szam2;
- for (int i = 1; i <= 16; i++)
- {
- szam2 = szam2 * eredmeny;
- Console.WriteLine(szam2);
- }
- break;
- case 18:
- Console.WriteLine("1-100 páros számok");
- for (int i = 2; i <= 100; i += 2)
- {
- Console.WriteLine(i);
- }
- break;
- case 19:
- int nov = 4;
- int a11 = 1;
- for (int i = 0; i <= 49; i++)
- {
- Console.WriteLine(a11);
- a11 = a11 + nov;
- }
- break;
- case 20:
- break;
- case 21:
- break;
- }
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement