Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Amit Lazar
- //#1
- int N;
- N = int.Parse(Console.ReadLine());
- int[] a = new int[N];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- int j = 0;
- bool vector;
- if (a[0] == 1)
- vector = true;
- else
- vector = false;
- while (j < a.Length - 1 && vector == true)
- {
- if (a[j + 1] - a[j] != 1)
- vector = false;
- else
- j++;
- }
- Console.WriteLine(vector);
- //#2
- const int N = 6;
- double[] a = new double[N];
- for (int i = 0; i < a.Length; i++)
- a[i] = double.Parse(Console.ReadLine());
- double[] b = new double[N];
- for (int i = 0; i < a.Length; i++)
- b[i] = a[i];
- int j = 1;
- while (j < a.Length)
- {
- if (a[j] > a[j - 1])
- {
- double holder = a[j];
- a[j] = a[j - 1];
- a[j - 1] = holder;
- if (j != 1)
- j--;
- }
- else
- {
- j++;
- }
- }
- for (int i = 0; i < a.Length; i++)
- {
- j = 0;
- while (b[j] != a[i])
- j++;
- j++;
- Console.Write("{0, -5}", j);
- }
- //#3
- int[] a = new int[15];
- for (int i = 0; i < a.Length; i++)
- a[i] = 0;
- int play, ammount, total = 0; ;
- Console.Write("Enter the play number: ");
- play = int.Parse(Console.ReadLine());
- Console.Write("Enter the ammount of tickets: ");
- ammount = int.Parse(Console.ReadLine());
- while (play != 0 && ammount != 0)
- {
- total += ammount;
- play--;
- a[play] += ammount;
- Console.Write("Enter the play number: ");
- play = int.Parse(Console.ReadLine());
- Console.Write("Enter the ammount of tickets: ");
- ammount = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < a.Length; i++)
- {
- double percent = a[i] * 100 / total;
- Console.WriteLine(percent);
- }
- //#4
- public static void Main(string[] args) {
- int[] a = new int[365];
- Random rnd = new Random();
- for (int i = 0; i < a.Length; i++)
- a[i] = rnd.Next(100);
- int rainy = 0, row = 1, max = 0;
- for (int i = 1; i < a.Length; i++)
- {
- if (a[i] == a[i - 1])
- {
- if (row == 2)
- {
- rainy++;
- }
- row++;
- }
- else
- row = 1;
- if (a[i] > max)
- max = i;
- }
- Console.WriteLine(rainy);
- Console.WriteLine(max);
- //#5
- bool[] a = new bool[1000]; //true for open, false for closed
- for (int i = 0; i < a.Length; i++)
- a[i] = true;
- for (int i = 6; i < a.Length; i++)
- {
- if (i % 2 == 0)
- {
- if (a[i])
- a[i] = false;
- else
- a[i] = true;
- }
- }
- for (int i = 2; i < a.Length; i++)
- {
- if (i - 2 % 3 == 0)
- {
- if (a[i])
- a[i] = false;
- else
- a[i] = true;
- }
- }
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i])
- Console.WriteLine(i);
- }
- //#6
- int[] N = new int[10];
- int[] M = new int[10];
- for (int i = 0; i < 10; i++)
- N[i] = int.Parse(Console.ReadLine());
- int end = 9, start = 0;
- for (int i = 0; i < N.Length; i++)
- {
- if (N[i] % 2 == 0)
- {
- M[end] = N[i];
- end--;
- }
- else
- {
- M[start] = N[i];
- start++;
- }
- }
- for (int i = 0; i < M.Length; i++)
- Console.Write("{0,-3}", M[i]);
- //#7
- int[] a = new int[6];
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- int[] b = new int[a.Length + 1];
- int sum = 0;
- b[0] = sum;
- for (int i = 1; i < a.Length + 1; i++)
- {
- sum += a[i - 1];
- b[i] = sum;
- }
- for (int i = 0; i < b.Length; i++)
- Console.Write("{0, -3}", b[i]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement