Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#1
- int[] arr = new int[10];
- int[] rev = new int[10];
- for (int i = 0; i < 10; i++)
- {
- int num = int.Parse(Console.ReadLine());
- arr[i] = num;
- rev[9 - i] = num;
- }
- for (int i = 0; i < 10; i++)
- Console.Write("{0,-3}", arr[i]);
- Console.WriteLine();
- Console.WriteLine();
- for (int i = 0; i < 10; i++)
- Console.Write("{0,-3}", rev[i]);
- }
- //#3
- int[] a = new int[8];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- int counter = 0;
- for (int i = 0; i < a.Length - 1; i++)
- if (a[i] > a[i + 1]) counter++;
- Console.WriteLine(counter);
- //#4
- int[] a = new int[7];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- int counter = 0, counter2 = 0;
- double avg = 0;
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] % 2 == 0)
- counter++;
- else
- {
- avg += a[i];
- counter2++;
- }
- }
- avg /= (double)counter2;
- Console.WriteLine("even: {0}, average: {1}", counter, avg);
- //#7
- //solution by Amit Lazar
- int[] a = new int[5];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- bool different = true;
- int j = 0;
- while (j < a.Length - 1 && different == true)
- {
- if (a[j] != a[j + 1])
- j++;
- else
- different = false;
- }
- Console.WriteLine(different);
- //#8
- int[] a = new int[10];
- Random rnd = new Random();
- for (int i = 0; i < a.Length; i++)
- a[i] = rnd.Next(4, 28);
- int times = 1, num = 0;
- for (int i = 1; i < a.Length; i++)
- {
- int lotime = 1;
- for (int j = 0; j < i; j++)
- if (a[j] == a[i]) lotime++;
- if (lotime >= times)
- {
- num = a[i];
- times = lotime;
- }
- Console.Write("{0,-3}", a[i]);
- }
- Console.WriteLine();
- Console.WriteLine("times: {0}, num: {1}", times, num);
- //#9
- int[] a = new int[10];
- int[] b = new int[10];
- for (int i = 0; i < 10; i++)
- a[i] = int.Parse(Console.ReadLine());
- for (int i = 0; i < 10; i++)
- b[i] = int.Parse(Console.ReadLine());
- int[] d = new int[10];
- int k = 0;
- for (int i = 0; i < b.Length; i++)
- {
- for (int j = 0; j < a.Length; j++)
- {
- if (a[i] == b[j])
- {
- d[k] = a[i];
- k++;
- }
- }
- }
- int[] c = new int[k];
- for (int i = 0; i < c.Length; i++)
- c[i] = d[i];
- for (int i = 0; i < c.Length; i++)
- Console.Write("{0, -3}", c[i]);
- //#10
- int[] a = new int[10];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- double avg = 0;
- for (int i = 0; i < a.Length; i++)
- avg += a[i];
- avg /= (double)a.Length;
- Console.WriteLine(avg);
- for (int i = 0; i < a.Length; i++)
- Console.WriteLine((double)a[i] - avg);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement