Advertisement
Guest User

עבודה בנושא לולאות

a guest
Oct 21st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.95 KB | None | 0 0
  1. משימה 1 א
  2.             for (int i = 1; i<=100;i++)
  3.             {
  4.                 Console.Write("amit");
  5.             }
  6. משימה 1 ב
  7.             Console.ForegroundColor = ConsoleColor.Blue;
  8.             for (int i = 1; i<=100;i++)
  9.             {
  10.                 Console.Write("amit");
  11.             }
  12. משימה 1 ג
  13.             Console.ForegroundColor = ConsoleColor.Blue;
  14.             for (int i = 1; i<=100;i++)
  15.             {
  16.                 Console.Write("amit   ");
  17.             }
  18. משימה 1 ד
  19.             int x;
  20.             Console.WriteLine("enter the number of times your name will apper");
  21.             x=int.Parse(Console.ReadLine());
  22.             Console.ForegroundColor = ConsoleColor.Blue;
  23.             for (int i = 1; i<=x;i++)
  24.             {
  25.                 Console.Write("amit");
  26.             }
  27. משימה 2
  28.  
  29.             for (int i = 30; i<=55;i=+3)
  30.             {
  31.                     Console.WriteLine(i);
  32.             }
  33. משימה 3
  34.             int x, y;
  35.             Console.WriteLine("enter first number");
  36.             y = int.Parse(Console.ReadLine());
  37.             Console.WriteLine("enter 2nd number");
  38.             x = int.Parse(Console.ReadLine());
  39.             if (x<y)
  40.                 for (int i=x; i<=y; i++)
  41.             {
  42.                     Console.WriteLine(i);
  43.             }
  44.             else
  45.                 for (int i = y; i <=x; i++)
  46.                 {
  47.                     Console.WriteLine(i);
  48.                 }
  49. משימה 4
  50.             int x;
  51.             Console.WriteLine("enter num");
  52.             x = int.Parse(Console.ReadLine());
  53.             for (int i = x; i <= 60; i = i + x)
  54.             {
  55.                 Console.WriteLine(i);
  56.             }
  57. משימה 5
  58.             int x;
  59.             for (int i = 1; 1 <= 7; i++)
  60.             {
  61.                 Console.WriteLine("enter num");
  62.                 x = int.Parse(Console.ReadLine());
  63.                 if (x > 0)
  64.                     Console.WriteLine("possitive");
  65.                 else
  66.                     Console.WriteLine("negative");
  67.             }
  68. משימה 6
  69.             int x, y, count = 0;
  70.             for (int i=1;i<=8;i++)
  71.             { Console.WriteLine("enter num");
  72.                 x = int.Parse(Console.ReadLine());
  73.                 y = (x % 10);
  74.                 Console.WriteLine("sifrat a ahadot hi:");
  75.                 Console.WriteLine(y);
  76.                 count = (count + y);
  77.             }
  78.             Console.WriteLine(count);
  79. משימה 7
  80.             int x;
  81.             for (int i = 1; i <= 7; i++)
  82.             {
  83.                 Console.WriteLine("enter num");
  84.                 x = int.Parse(Console.ReadLine());
  85.                 if ((x >= 100) || (x <= -100))
  86.                     Console.WriteLine("misapar baal 3 sfarot o yoter");
  87.                 else
  88.                     Console.WriteLine("mispar baal pahot me 3 sfarot");
  89.             }
  90. משימה 8
  91.             int x , y ,z,n=0;
  92.             for (int i =1;i<=5;i++)
  93.             {
  94.                 Console.WriteLine("enter num");
  95.                 x = int.Parse(Console.ReadLine());
  96.                 y = x % 10;
  97.                 z = (x/10);
  98.                 if ((x > 9) && (x < 100) || (x<-9)&&(x>-100))
  99.                 {
  100.                     Console.WriteLine("shum a sfarot:");
  101.                     Console.WriteLine(y+z);
  102.                     if (y + z > n)
  103.                         n = y + z;
  104.                 }
  105.                 else
  106.                     Console.WriteLine("error");
  107.                
  108.             }
  109.             Console.WriteLine("shum as sfarot as gavoa be yoter hu:");
  110.             Console.WriteLine(n);
  111. משימה 9
  112.             int num,n,count=0;
  113.             for (int i = 1; i <= 10; i++)
  114.             {
  115.                 Console.WriteLine("enter num");
  116.                 num = int.Parse(Console.ReadLine());
  117.                 n = (num % 7);
  118.                 if (n == 0)
  119.                     count = (count + 1);
  120.             }
  121.             if (count > 0)
  122.                 Console.WriteLine("yesh lefahot mispar ehad she mithalek be 7");
  123. משימה 10
  124.             int tzion, avg1=0,avg2=0;
  125.             for (int i = 1; i <= 12; i++)
  126.  
  127.             {
  128.                 Console.WriteLine("enter tzion");
  129.                 tzion = int.Parse(Console.ReadLine());
  130.                 avg1 = (avg1 + tzion);
  131.             }
  132.             Console.WriteLine("memutza shlish rishon:");
  133.             Console.WriteLine(avg1/12);
  134.             for (int i = 1; i <= 12; i++)
  135.             {
  136.                 Console.WriteLine("enter tzion");
  137.                 tzion = int.Parse(Console.ReadLine());
  138.                 avg2 = (avg2 + tzion);
  139.             }
  140.             Console.WriteLine("memutza shlish sheni:");
  141.             Console.WriteLine(avg2/12);
  142.             if (avg1 == avg2)
  143.                 Console.WriteLine("memutza lo hishtana");
  144.             else
  145.                 if (avg1 > avg2)
  146.                 Console.WriteLine("nesiga ba memutza");
  147.             else
  148.                 Console.WriteLine("shipur ba memutza");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement