Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. /* 1.
  2. * while (true)
  3. {
  4. for(int i = 0; i<1001; i++)
  5. {
  6. if ((i % 3) == 0)
  7. {
  8. Console.WriteLine(i);
  9. }
  10. }
  11. Console.ReadKey(true);
  12. }
  13. */
  14.  
  15. /* 2.
  16. Random random = new Random();
  17. int i = random.Next(1, 100);
  18. while (true)
  19. {
  20.  
  21. int j;
  22. Console.WriteLine("Anna luku: ");
  23. j = Convert.ToInt32(Console.ReadLine());
  24. if (j < i)
  25. {
  26. Console.WriteLine("Liian pieni arvaus");
  27.  
  28. } else if (j > i)
  29. {
  30. Console.WriteLine("Liian suuri arvaus");
  31.  
  32. }
  33. else
  34. {
  35. Console.WriteLine("Oikein!");
  36.  
  37. }
  38.  
  39. }
  40. */
  41.  
  42.  
  43. /* 3 & 4
  44. Console.WriteLine("Kuinka monta lukua haluat syöttää?");
  45. int y = Convert.ToInt32(Console.ReadLine());
  46. int x = 0;
  47. int j;
  48. int i;
  49. int sum;
  50. int ka;
  51. for (i = 0; i < y; i++)
  52. {
  53. Console.WriteLine("Anna luku: ");
  54. j = Convert.ToInt32(Console.ReadLine());
  55.  
  56. x += j;
  57.  
  58. }
  59. sum = x;
  60. ka = x / y;
  61.  
  62. Console.WriteLine($"Summa ja keskiarvo ovat {sum} ja {ka}");
  63. Console.ReadKey(true);
  64. */
  65.  
  66. /* 5
  67. DataTable dt = new DataTable();
  68. dt.Columns.Add("Name", typeof(string));
  69. Console.WriteLine("Kuinka monta ystävää sinulla on?");
  70. int y = Convert.ToInt32(Console.ReadLine());
  71.  
  72. for (int i = 0; i < y; i++)
  73. {
  74. Console.WriteLine("Anna ystäväsi nimi:");
  75. dt.Rows.Add(Console.ReadLine());
  76. };
  77.  
  78. foreach (DataRow row in dt.Rows)
  79. {
  80. Console.WriteLine();
  81. for (int x = 0; x < dt.Columns.Count; x++)
  82. {
  83. Console.Write(row[x].ToString() + " ");
  84. }
  85. }
  86.  
  87. Console.ReadKey(true);
  88. */
  89. /* 6.
  90. DataTable dt = new DataTable();
  91. dt.Columns.Add("Luku", typeof(string));
  92. Console.WriteLine("Anna kymmenen lukua");
  93.  
  94.  
  95. for (int i = 0; i < 10; i++)
  96. {
  97. Console.WriteLine("Anna luku:");
  98. dt.Rows.Add(Console.ReadLine());
  99. };
  100.  
  101. DataTable reversedt = dt.Clone();
  102.  
  103. for (int i = dt.Rows.Count - 1; i >= 0; i--)
  104. {
  105. reversedt.ImportRow(dt.Rows[i]);
  106. }
  107.  
  108. foreach (DataRow row in reversedt.Rows)
  109. {
  110. Console.WriteLine();
  111. for (int x = 0; x < reversedt.Columns.Count; x++)
  112. {
  113. Console.Write(row[x].ToString() + " ");
  114. }
  115. }
  116.  
  117. Console.ReadKey(true);
  118. */
  119. /* 7
  120. Console.WriteLine("Kuinka monta tähteä tulostetaan?");
  121. int i = Convert.ToInt32(Console.ReadLine());
  122.  
  123. for(int x = 0; i>x; x++)
  124. {
  125. Console.Write("*");
  126. }
  127. Console.ReadKey(true);
  128. */
  129. /* 8.
  130. Console.WriteLine("Anna suorakaiteen kanta:");
  131. int i = Convert.ToInt32(Console.ReadLine());
  132.  
  133. Console.WriteLine("Anna suorakaiteen korkeus:");
  134. int y = Convert.ToInt32(Console.ReadLine());
  135.  
  136. for (int x = 1; x <= y; x++)
  137. {
  138.  
  139. for (int j = 1; j <= i; j++)
  140. {
  141. Console.Write("#");
  142. }
  143.  
  144. Console.WriteLine();
  145. }
  146. Console.ReadKey(true);
  147. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement