Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 1.
- * while (true)
- {
- for(int i = 0; i<1001; i++)
- {
- if ((i % 3) == 0)
- {
- Console.WriteLine(i);
- }
- }
- Console.ReadKey(true);
- }
- */
- /* 2.
- Random random = new Random();
- int i = random.Next(1, 100);
- while (true)
- {
- int j;
- Console.WriteLine("Anna luku: ");
- j = Convert.ToInt32(Console.ReadLine());
- if (j < i)
- {
- Console.WriteLine("Liian pieni arvaus");
- } else if (j > i)
- {
- Console.WriteLine("Liian suuri arvaus");
- }
- else
- {
- Console.WriteLine("Oikein!");
- }
- }
- */
- /* 3 & 4
- Console.WriteLine("Kuinka monta lukua haluat syöttää?");
- int y = Convert.ToInt32(Console.ReadLine());
- int x = 0;
- int j;
- int i;
- int sum;
- int ka;
- for (i = 0; i < y; i++)
- {
- Console.WriteLine("Anna luku: ");
- j = Convert.ToInt32(Console.ReadLine());
- x += j;
- }
- sum = x;
- ka = x / y;
- Console.WriteLine($"Summa ja keskiarvo ovat {sum} ja {ka}");
- Console.ReadKey(true);
- */
- /* 5
- DataTable dt = new DataTable();
- dt.Columns.Add("Name", typeof(string));
- Console.WriteLine("Kuinka monta ystävää sinulla on?");
- int y = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < y; i++)
- {
- Console.WriteLine("Anna ystäväsi nimi:");
- dt.Rows.Add(Console.ReadLine());
- };
- foreach (DataRow row in dt.Rows)
- {
- Console.WriteLine();
- for (int x = 0; x < dt.Columns.Count; x++)
- {
- Console.Write(row[x].ToString() + " ");
- }
- }
- Console.ReadKey(true);
- */
- /* 6.
- DataTable dt = new DataTable();
- dt.Columns.Add("Luku", typeof(string));
- Console.WriteLine("Anna kymmenen lukua");
- for (int i = 0; i < 10; i++)
- {
- Console.WriteLine("Anna luku:");
- dt.Rows.Add(Console.ReadLine());
- };
- DataTable reversedt = dt.Clone();
- for (int i = dt.Rows.Count - 1; i >= 0; i--)
- {
- reversedt.ImportRow(dt.Rows[i]);
- }
- foreach (DataRow row in reversedt.Rows)
- {
- Console.WriteLine();
- for (int x = 0; x < reversedt.Columns.Count; x++)
- {
- Console.Write(row[x].ToString() + " ");
- }
- }
- Console.ReadKey(true);
- */
- /* 7
- Console.WriteLine("Kuinka monta tähteä tulostetaan?");
- int i = Convert.ToInt32(Console.ReadLine());
- for(int x = 0; i>x; x++)
- {
- Console.Write("*");
- }
- Console.ReadKey(true);
- */
- /* 8.
- Console.WriteLine("Anna suorakaiteen kanta:");
- int i = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Anna suorakaiteen korkeus:");
- int y = Convert.ToInt32(Console.ReadLine());
- for (int x = 1; x <= y; x++)
- {
- for (int j = 1; j <= i; j++)
- {
- Console.Write("#");
- }
- Console.WriteLine();
- }
- Console.ReadKey(true);
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement