Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication {
- class Class {
- static public void Main() {
- int[] msv = new int[20];
- Random r = new Random();
- Console.WriteLine("Исходный массив:");
- for (int i = 0; i < msv.Length; i++) {
- msv[i] = r.Next(0, 10);
- Console.Write(msv[i] + " ");
- }
- int n = 0;
- for (int i = 0; i < msv.Length; i++) {
- if (msv[i] % 2 != 0) ++ n;
- }
- int[] msv2 = new int[n];
- int a = 0;
- foreach (int e in msv) {
- if (e % 2 != 0)
- msv2[a++] = e;
- }
- Console.WriteLine("\n\nПосле удаления четных:");
- foreach (int i in msv2){
- Console.Write(i + " ");
- }
- Console.WriteLine();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement