Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LEKCJA 1
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace podstawy_lab1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int ls = 0;
- int musi = 0;
- int licz = 0;
- Console.Write("ile studentow: ");
- ls = int.Parse(Console.ReadLine());
- musi = ls;
- if (ls > 19)
- {
- while (musi > 19)
- {
- licz++;
- musi--;
- }
- Console.WriteLine("studentow jest za duzo a opisic musi: " + licz);
- }
- else if (ls < 19)
- {
- while (musi < 19)
- {
- licz++;
- musi++;
- }
- Console.WriteLine("studentow jest wystarczajaco i brakuje: " + licz);
- }
- else
- Console.WriteLine("idealnie");
- /* int ls = 0;
- Console.Write("ile studentow: ");
- ls = int.Parse(Console.ReadLine());
- Console.WriteLine("ilosc studentow: " + ls);
- */
- /* double palce = 10.0;
- double uciete = 0.0;
- Console.WriteLine("ma palcy" + palce);
- Console.Write("ile ucielo: ");
- uciete = double.Parse(Console.ReadLine());
- palce = palce - uciete;
- Console.WriteLine("a teraz ma palcy" + palce);
- */
- /* Console.WriteLine("ilosc studentow: " + ls);
- ls = 19;
- Console.WriteLine("ilosc studentow: " + ls);
- ls++;
- Console.WriteLine("ilosc studentow: " + ls);
- */
- Console.ReadKey();
- }
- }
- }
- //LEKCJA2
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int licz=0;
- Console.Write("for \n");
- for (licz=1;licz<=100;licz++)
- {
- Console.Write(licz + " ");
- }
- Console.Write(" \n while \n");
- licz = 1;
- while (licz<=100)
- {
- Console.Write(licz + " ");
- licz++;
- }
- Console.Write(" \n do while \n");
- licz = 1;
- do {
- Console.Write(licz + " ");
- licz++;
- } while (licz <= 100);
- Console.Write("\n\n\n\n");
- for (int a = 0; a > -3; a--)
- {
- for (int b = 0; b <= a; b++)
- {
- Console.Write("");
- }
- Console.Write("*************\n");
- }
- Console.Write(" \n");
- for (int a=1;a<=20;a++)
- {
- if(a%1==0)
- Console.Write("*"+a+"\n");
- for (int b=1;b<a;b++)
- {
- Console.Write("*");
- }
- }
- Console.Write(" \n Silnia \n \n");
- Console.Write("Silnia z 5 \n");
- Console.Write("!5=1*2*3*4*5=120 \n");
- int silnia = 1;
- int licznik=1;
- int przepisywanie=0;
- licz = 1;
- Console.Write("Wpisz silnie: !");
- silnia=int.Parse(Console.ReadLine());
- while(licznik<=silnia)
- {
- licz = licz * licznik;
- licznik++;
- przepisywanie = licz;
- }
- Console.WriteLine("\n\n|************** !" + "SILNIA" + " **************|");
- Console.WriteLine("|*************** !"+silnia+"="+ przepisywanie+ " ***************| \n\n\n\n\n\n\n");
- int lol = 1;
- int potega=1;
- int pomoc = 1;
- int co = 0;
- Console.Write("Wpisz liczbe: ");
- licznik = int.Parse(Console.ReadLine());
- Console.Write("\n Wpisz potega: ");
- potega = int.Parse(Console.ReadLine());
- co = licznik;
- while (lol<potega)
- {
- if (potega == 0)
- Console.Write("\n wynik: 1");
- else
- {
- co = co * licznik;
- lol++;
- }
- pomoc=co;
- }
- Console.Write("\n wynik: "+pomoc+"\n\n\n OR\n");
- for (int z = 1; z <= 100; z++)
- {
- if (z % 3 == 0 || z%5==0)
- Console.Write("|" + z + "|");
- }
- Console.Write("\n \n\n\n\n\n\n\n AND\n");
- for (int z = 1; z <= 100; z++)
- {
- if (z % 3 == 0 && z % 5 == 0)
- Console.Write("|" + z + "|");
- }
- Console.Write("\n \n\n\n\n\n\n\n OR i AND\n");
- for (int z = 1; z <= 100; z++)
- {
- if ((z % 3 == 0 || z % 5 == 0) && (z % 2 == 0 || z % 4 == 0))
- Console.Write("|" + z + "|");
- }
- Console.ReadKey();
- }
- }
- }
- //LEKCJA 3
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication32
- {
- class Program
- {
- static void Main(string[] args)
- {
- int result = 1;
- while(true)
- {
- Console.WriteLine("Podaj wartosc operacji: ");
- int value= int.Parse(Console.ReadLine());
- if (value == 0)
- {
- break;
- }
- Console.WriteLine("Wybierz operacje: ");
- Console.WriteLine("1)Dodawwanie/odejmowanie");
- Console.WriteLine("2)Manozenie");
- Console.WriteLine("3)Dzielenie");
- string decyzja = Console.ReadLine();
- /* if( decyzja == "1")
- {
- result += value;
- Console.WriteLine("Nowa Wartosc: " + result);
- }
- else if (decyzja == "2")
- {
- result *= value;
- Console.WriteLine("Nowa Wartosc: " + result);
- }
- else if (decyzja == "3")
- {
- result /= value;
- Console.WriteLine("Nowa Wartosc: " + result);
- }
- else Console.WriteLine("Nierozpoznano poleceniea");
- */
- switch (decyzja)
- {
- case "1":
- result += value;
- break;
- case "2":
- result += value;
- break;
- case "3":
- result += value;
- break;
- default: Console.WriteLine("Nierozpoznano poleceniea");
- break;
- }
- }
- Console.WriteLine("Rezultat: " + result);
- Console.ReadKey();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication32
- {
- class Program
- {
- static void Main(string[] args)
- {
- int result = 1;
- while(true)
- {
- Console.WriteLine("Podaj wartosc operacji: ");
- int value= int.Parse(Console.ReadLine());
- if (value == 0)
- {
- break;
- }
- showmenu();
- string decyzja = Console.ReadLine();
- result= Operacje(decyzja, value, result);
- }
- Console.WriteLine("Rezultat: " + result);
- Console.ReadKey();
- }
- static void showmenu()
- {
- Console.WriteLine("Wybierz operacje: ");
- Console.WriteLine("1)Dodawwanie/odejmowanie");
- Console.WriteLine("2)Manozenie");
- Console.WriteLine("3)Dzielenie");
- }
- static int Operacje(string decyzja, int value, int result)
- {
- switch (decyzja)
- {
- case "1":
- result += value;
- break;
- case "2":
- result += value;
- break;
- case "3":
- result += value;
- break;
- default: Console.WriteLine("Nierozpoznano poleceniea");
- break;
- }
- return result;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication33
- {
- class Program
- {
- static void Main(string[] args)
- {
- int wynik = 0;
- while (true) {
- int pierwsza = liczba();
- int druga = liczba();
- if (pierwsza == 0 && druga == 0)
- break;
- Console.Write("podaj operacje (+,-,*,/): ");
- string operacja = Console.ReadLine();
- switch (operacja)
- {
- case "+":
- wynik = pierwsza + druga;
- Console.WriteLine("Wynik= " + wynik);
- break;
- case "-":
- wynik = pierwsza - druga;
- Console.WriteLine("Wynik= " + wynik);
- break;
- case "*":
- wynik = pierwsza * druga;
- Console.WriteLine("Wynik= " + wynik);
- break;
- case "/":
- if (druga == 0)
- Console.WriteLine("blad dzielenia");
- else
- wynik = pierwsza / druga;
- Console.WriteLine("Wynik= " + wynik);
- break;
- default:
- Console.WriteLine("Operacja nie rozpoznana");
- break;
- }
- }
- Console.WriteLine("koniec");
- // Console.ReadKey();
- //Environment
- }
- static int liczba ()
- {
- Console.Write("\n wypisz liczbe: ");
- int liczba = int.Parse(Console.ReadLine());
- return liczba;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement