Advertisement
abasar

while 1111

Nov 11th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. //#1
  2.             int girls = 0, boys = 0, mone = 0;
  3.             while (girls != -1 && boys != -1)
  4.             {
  5.                 boys = int.Parse(Console.ReadLine());
  6.                 girls = int.Parse(Console.ReadLine());
  7.                 if (boys == girls)
  8.                     mone++;
  9.             }
  10.             Console.WriteLine(mone);
  11.  
  12. //#2
  13.             Random rnd = new Random();
  14.             int x, y, z;
  15.         x = int.Parse(Console.ReadLine());
  16. y = int.Parse(Console.ReadLine());
  17.             while (x != 0 && y != 0)
  18.             {
  19.                 if (x > y)
  20.                     z = rnd.Next(y + 1, x);
  21.                 else
  22.                     z = rnd.Next(x + 1, y);
  23.                 Console.WriteLine(z);
  24.                 x = int.Parse(Console.ReadLine());
  25.                 y = int.Parse(Console.ReadLine());
  26. }
  27.  
  28. //#3
  29.             int x, sum = 0, mone = 0;
  30.             x = int.Parse(Console.ReadLine());
  31.             while (x != 1000 && x > 999 && x < 10000)
  32.             {
  33.                 if (x % 10 > x / 100 % 10)
  34.                     sum += x;
  35.                 if (x / 10 % 10 % 2 == 0 && x / 1000 == 1)
  36.                     mone++;
  37.                 x = int.Parse(Console.ReadLine());
  38.             }
  39.             Console.WriteLine("{0} {1}", sum, mone);
  40.  
  41. //#4
  42.             int x;
  43.             x = int.Parse(Console.ReadLine());
  44.             while (x > 9 && x < 100)
  45.             {
  46.                 if (x / 10 + 2 == x % 10)
  47.                     Console.WriteLine(x);
  48.                 x = int.Parse(Console.ReadLine());
  49.             }
  50.  
  51. //#5
  52.             int x;
  53.             x = int.Parse(Console.ReadLine());
  54.             while (x != 0)
  55.             {
  56.                 int i;
  57.                 string r = "rishoni";
  58.                 for (i = 2; i < x; i++)
  59.                 {
  60.                     if (x % i == 0)
  61.                         r = "lo";
  62.                 }
  63.         if (x==1)
  64.             r="lo";
  65.                 Console.WriteLine(r);
  66.                 x = int.Parse(Console.ReadLine());
  67. }
  68. //#6
  69.             int x, digits = 1, sum=0;
  70.             x = int.Parse(Console.ReadLine());
  71.             while (x != -1) {
  72.                 while (x / 10 != 0)
  73.                 {
  74.                     digits++;
  75.                     sum += x % 10;
  76.                     x /= 10;
  77.                 }
  78.                 sum += x % 10;
  79.                 Console.WriteLine("number of digits: {0}, sum of digits: {1}", digits, sum);
  80.                 x = int.Parse(Console.ReadLine());
  81.                 digits = 1;
  82.                 sum = 0;
  83.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement