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.Text.RegularExpressions;
- namespace tort
- {
- // Coded by Metts
- // metts.blog.hu
- // http://metts.blog.hu/2012/05/15/emelt_informatika_erettsegi_2012_majus_tortek
- class Program
- {
- static int lnko(int a, int b) //2. feladat
- {
- int ret = 0;
- if (a == b)
- ret = a;
- if (a < b)
- ret = lnko(a, b-a);
- if (a > b)
- ret = lnko(a - b, b);
- return ret;
- }
- static void szorzas(int szamlalo, int nevezo, int szamlalo2, int nevezo2)
- {
- int felso = szamlalo * szamlalo2;
- int also = nevezo * nevezo2;
- Console.WriteLine("{0}/{1} * {2}/{3} = {4}/{5} = {6}/{7}", szamlalo, nevezo, szamlalo2, nevezo2, felso, also,felso / lnko(felso,also),also / lnko(felso,also));
- }
- static void Main(string[] args)
- {
- int szamlalo = 0;
- int nevezo = 0;
- #region 1. Feladat
- Console.WriteLine("1. Feladat Adja meg a számlálót: ");
- szamlalo = int.Parse(Console.ReadLine());
- Console.WriteLine("1. feladat Adja meg a nevezőt: ");
- nevezo = int.Parse(Console.ReadLine());
- decimal osztva = (decimal)szamlalo / nevezo;
- string result = osztva.ToString();
- Regex regex = new Regex("^[0-9]+$");
- Console.WriteLine("A szám: ");
- if (regex.IsMatch(result))
- Console.WriteLine(int.Parse(result));
- else
- Console.WriteLine("Nem egész");
- #endregion
- #region 3. Feladat
- Console.WriteLine("3. feladat egyszerűítés");
- int lko = lnko(szamlalo, nevezo);
- Console.WriteLine("{0}/{1} = {2}/{3}", szamlalo, nevezo, szamlalo / lko, nevezo / lko);
- #endregion
- #region 4.Feladat
- Console.WriteLine("4. feladat szorzás");
- int szamlalo2 = 0;
- int nevezo2 = 0;
- Console.WriteLine("4. Feladat Adja meg a számlálót: ");
- szamlalo2 = int.Parse(Console.ReadLine());
- Console.WriteLine("4. feladat Adja meg a nevezőt: ");
- nevezo2 = int.Parse(Console.ReadLine());
- szorzas(szamlalo, nevezo, szamlalo2, nevezo2);
- #endregion
- #region 5.Feladat
- #endregion
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement