Advertisement
darkman110697

STUDIA programowanie z lachem

Oct 15th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.16 KB | None | 0 0
  1. //LEKCJA 1
  2.  
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace podstawy_lab1
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             int ls = 0;
  17.             int musi = 0;
  18.             int licz = 0;
  19.            
  20.             Console.Write("ile studentow: ");
  21.             ls = int.Parse(Console.ReadLine());
  22.            
  23.                 musi = ls;
  24.  
  25.             if (ls > 19)
  26.             {
  27.                 while (musi > 19)
  28.                 {
  29.                     licz++;
  30.                     musi--;
  31.                 }
  32.                 Console.WriteLine("studentow jest za duzo a opisic musi: " + licz);
  33.             }
  34.             else if (ls < 19)
  35.             {
  36.                 while (musi < 19)
  37.                 {
  38.                     licz++;
  39.                     musi++;
  40.                 }
  41.  
  42.  
  43.                 Console.WriteLine("studentow jest wystarczajaco i brakuje: " + licz);
  44.             }
  45.             else
  46.                 Console.WriteLine("idealnie");
  47.  
  48.                
  49.  
  50.  
  51.  
  52.  
  53.             /* int ls = 0;
  54.             Console.Write("ile studentow: ");
  55.             ls = int.Parse(Console.ReadLine());
  56.             Console.WriteLine("ilosc studentow: " + ls);
  57.             */
  58.  
  59.             /*  double palce = 10.0;
  60.               double uciete = 0.0;
  61.               Console.WriteLine("ma palcy" + palce);
  62.               Console.Write("ile ucielo: ");
  63.               uciete = double.Parse(Console.ReadLine());
  64.               palce = palce - uciete;
  65.               Console.WriteLine("a teraz ma palcy" + palce);
  66.               */
  67.  
  68.  
  69.             /* Console.WriteLine("ilosc studentow: " + ls);
  70.             ls = 19;
  71.             Console.WriteLine("ilosc studentow: " + ls);
  72.             ls++;
  73.             Console.WriteLine("ilosc studentow: " + ls);
  74.             */
  75.             Console.ReadKey();
  76.         }
  77.     }
  78. }
  79.  
  80.  
  81.  
  82. //LEKCJA2
  83.  
  84.  
  85. using System;
  86. using System.Collections.Generic;
  87. using System.Linq;
  88. using System.Text;
  89. using System.Threading.Tasks;
  90.  
  91. namespace ConsoleApplication1
  92. {
  93.     class Program
  94.     {
  95.         static void Main(string[] args)
  96.         {
  97.            
  98.  
  99.  
  100.             int licz=0;
  101.             Console.Write("for \n");
  102.             for (licz=1;licz<=100;licz++)
  103.             {
  104.                 Console.Write(licz + " ");
  105.             }
  106.             Console.Write(" \n while \n");
  107.             licz = 1;
  108.             while (licz<=100)
  109.             {
  110.                 Console.Write(licz + " ");
  111.                 licz++;
  112.  
  113.             }
  114.             Console.Write(" \n do while \n");
  115.  
  116.             licz = 1;
  117.             do {
  118.                 Console.Write(licz + " ");
  119.                 licz++;
  120.             } while (licz <= 100);
  121.             Console.Write("\n\n\n\n");
  122.  
  123.             for (int a = 0; a > -3; a--)
  124.             {
  125.  
  126.                 for (int b = 0; b <= a; b++)
  127.                 {
  128.                     Console.Write("");
  129.  
  130.                 }
  131.                 Console.Write("*************\n");
  132.             }
  133.  
  134.  
  135.  
  136.             Console.Write(" \n");
  137.             for (int a=1;a<=20;a++)
  138.             {
  139.                 if(a%1==0)
  140.                 Console.Write("*"+a+"\n");
  141.              
  142.                 for (int b=1;b<a;b++)
  143.                 {
  144.  
  145.                     Console.Write("*");
  146.  
  147.                 }
  148.              
  149.             }
  150.  
  151.             Console.Write(" \n Silnia \n \n");
  152.  
  153.             Console.Write("Silnia z 5 \n");
  154.             Console.Write("!5=1*2*3*4*5=120 \n");
  155.  
  156.             int silnia = 1;
  157.             int licznik=1;
  158.             int przepisywanie=0;
  159.             licz = 1;
  160.             Console.Write("Wpisz silnie: !");
  161.             silnia=int.Parse(Console.ReadLine());
  162.             while(licznik<=silnia)
  163.             {
  164.                 licz = licz * licznik;
  165.                 licznik++;
  166.                 przepisywanie = licz;
  167.             }
  168.             Console.WriteLine("\n\n|**************   !" + "SILNIA" + "   **************|");
  169.             Console.WriteLine("|***************   !"+silnia+"="+ przepisywanie+ "   ***************| \n\n\n\n\n\n\n");
  170.             int lol = 1;
  171.             int potega=1;
  172.             int pomoc = 1;
  173.             int co = 0;
  174.             Console.Write("Wpisz liczbe: ");
  175.             licznik = int.Parse(Console.ReadLine());
  176.             Console.Write("\n Wpisz potega: ");
  177.            potega = int.Parse(Console.ReadLine());
  178.             co = licznik;
  179.             while (lol<potega)
  180.             {
  181.                 if (potega == 0)
  182.                     Console.Write("\n wynik: 1");
  183.                 else
  184.                 {
  185.                     co = co * licznik;
  186.                     lol++;
  187.                 }
  188.                  pomoc=co;
  189.             }
  190.             Console.Write("\n wynik: "+pomoc+"\n\n\n OR\n");
  191.  
  192.             for (int z = 1; z <= 100; z++)
  193.             {
  194.                 if (z % 3 == 0 || z%5==0)
  195.                     Console.Write("|" + z + "|");
  196.             }
  197.  
  198.  
  199.             Console.Write("\n \n\n\n\n\n\n\n AND\n");
  200.             for (int z = 1; z <= 100; z++)
  201.             {
  202.                 if (z % 3 == 0 && z % 5 == 0)
  203.                     Console.Write("|" + z + "|");
  204.             }
  205.  
  206.             Console.Write("\n \n\n\n\n\n\n\n OR i AND\n");
  207.             for (int z = 1; z <= 100; z++)
  208.             {
  209.                 if ((z % 3 == 0 || z % 5 == 0) && (z % 2 == 0 || z % 4 == 0))
  210.                     Console.Write("|" + z + "|");
  211.             }
  212.  
  213.  
  214.  
  215.  
  216.  
  217.             Console.ReadKey();
  218.         }
  219.     }
  220. }
  221.  
  222.  
  223. //LEKCJA 3
  224.  
  225.  
  226. using System;
  227. using System.Collections.Generic;
  228. using System.Linq;
  229. using System.Text;
  230. using System.Threading.Tasks;
  231.  
  232. namespace ConsoleApplication32
  233. {
  234.     class Program
  235.     {
  236.         static void Main(string[] args)
  237.         {
  238.             int result = 1;    
  239.                 while(true)
  240.             {
  241.                 Console.WriteLine("Podaj wartosc operacji: ");
  242.  
  243.                int value= int.Parse(Console.ReadLine());
  244.                 if (value == 0)
  245.                 {
  246.                     break;
  247.                 }
  248.                
  249.                 Console.WriteLine("Wybierz operacje: ");
  250.                 Console.WriteLine("1)Dodawwanie/odejmowanie");
  251.                 Console.WriteLine("2)Manozenie");
  252.                 Console.WriteLine("3)Dzielenie");
  253.                 string decyzja = Console.ReadLine();
  254.  
  255.            /* if( decyzja == "1")
  256.                 {
  257.                     result += value;
  258.                     Console.WriteLine("Nowa Wartosc: " + result);
  259.  
  260.                 }
  261.                 else if  (decyzja == "2")
  262.                 {
  263.                     result *= value;
  264.                     Console.WriteLine("Nowa Wartosc: " + result);
  265.  
  266.                 }
  267.                 else if  (decyzja == "3")
  268.                 {
  269.                     result /= value;
  270.                     Console.WriteLine("Nowa Wartosc: " + result);
  271.  
  272.                 }
  273.                 else Console.WriteLine("Nierozpoznano poleceniea");
  274.  
  275.  
  276.  
  277. */
  278.  
  279.                 switch (decyzja)
  280.                 {
  281.                     case "1":
  282.                         result += value;
  283.                         break;
  284.                     case "2":
  285.                         result += value;
  286.                         break;
  287.                     case "3":
  288.                         result += value;
  289.                         break;
  290.                     default: Console.WriteLine("Nierozpoznano poleceniea");
  291.                         break;
  292.  
  293.                 }
  294.             }
  295.             Console.WriteLine("Rezultat: " + result);
  296.  
  297.  
  298.  
  299.             Console.ReadKey();
  300.         }
  301.     }
  302. }
  303.  
  304.  
  305.  
  306.  
  307. using System;
  308. using System.Collections.Generic;
  309. using System.Linq;
  310. using System.Text;
  311. using System.Threading.Tasks;
  312.  
  313. namespace ConsoleApplication32
  314. {
  315.     class Program
  316.     {
  317.         static void Main(string[] args)
  318.         {
  319.             int result = 1;    
  320.                 while(true)
  321.             {
  322.                 Console.WriteLine("Podaj wartosc operacji: ");
  323.  
  324.                int value= int.Parse(Console.ReadLine());
  325.                 if (value == 0)
  326.                 {
  327.                     break;
  328.                 }
  329.                 showmenu();
  330.                
  331.                 string decyzja = Console.ReadLine();
  332.               result= Operacje(decyzja, value, result);
  333.  
  334.  
  335.  
  336.             }
  337.             Console.WriteLine("Rezultat: " + result);
  338.  
  339.  
  340.  
  341.             Console.ReadKey();
  342.         }
  343.  
  344.  
  345.       static void showmenu()
  346.         {
  347.             Console.WriteLine("Wybierz operacje: ");
  348.             Console.WriteLine("1)Dodawwanie/odejmowanie");
  349.             Console.WriteLine("2)Manozenie");
  350.             Console.WriteLine("3)Dzielenie");
  351.         }
  352.  
  353.         static int Operacje(string decyzja, int value, int result)
  354.         {
  355.               switch (decyzja)
  356.                 {
  357.                     case "1":
  358.                         result += value;
  359.                 break;
  360.                     case "2":
  361.                         result += value;
  362.                 break;
  363.                     case "3":
  364.                         result += value;
  365.                 break;
  366.                 default: Console.WriteLine("Nierozpoznano poleceniea");
  367.                 break;
  368.  
  369.             }
  370.             return result;
  371.         }
  372.  
  373.     }
  374. }
  375.  
  376.  
  377.  
  378.  
  379. using System;
  380. using System.Collections.Generic;
  381. using System.Linq;
  382. using System.Text;
  383. using System.Threading.Tasks;
  384.  
  385. namespace ConsoleApplication33
  386. {
  387.     class Program
  388.     {
  389.         static void Main(string[] args)
  390.         {
  391.             int wynik = 0;
  392.            
  393.             while (true) {
  394.  
  395.                int pierwsza = liczba();
  396.                int druga = liczba();
  397.            
  398.  
  399.                 if (pierwsza == 0 && druga == 0)
  400.                     break;
  401.             Console.Write("podaj operacje (+,-,*,/): ");
  402.             string operacja = Console.ReadLine();
  403.  
  404.             switch (operacja)
  405.             {
  406.                 case "+":
  407.                     wynik = pierwsza + druga;
  408.                         Console.WriteLine("Wynik= " + wynik);
  409.                         break;
  410.                 case "-":
  411.                     wynik = pierwsza - druga;
  412.                         Console.WriteLine("Wynik= " + wynik);
  413.                         break;
  414.                 case "*":
  415.                     wynik = pierwsza * druga;
  416.                         Console.WriteLine("Wynik= " + wynik);
  417.                         break;
  418.  
  419.                 case "/":
  420.                         if (druga == 0)
  421.                             Console.WriteLine("blad dzielenia");
  422.                         else
  423.                        
  424.                             wynik = pierwsza / druga;
  425.                             Console.WriteLine("Wynik= " + wynik);
  426.                             break;
  427.                        
  428.  
  429.                 default:
  430.                     Console.WriteLine("Operacja nie rozpoznana");
  431.                     break;
  432.  
  433.             }
  434.             }
  435.             Console.WriteLine("koniec");
  436.            
  437.             // Console.ReadKey();
  438.             //Environment
  439.         }
  440.  
  441.  
  442.         static int liczba ()
  443.         {
  444.             Console.Write("\n wypisz liczbe: ");
  445.             int liczba = int.Parse(Console.ReadLine());
  446.             return liczba;
  447.         }
  448.     }
  449. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement