Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *Rimuovere da un vettore i numeri multipli di k
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] v = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- Console.WriteLine("Vettore di partenza:");
- StampaVettore(v);
- Console.WriteLine("Inserisci k:");
- int k = Convert.ToInt32(Console.ReadLine());
- v = v.Where(x => x % k != 0).ToArray();
- Console.WriteLine("\n\nVettore senza multipli di " + k + ":");
- StampaVettore(v);
- Console.ReadKey();
- }
- static void StampaVettore(int[] v)
- {
- foreach (int i in v)
- Console.WriteLine(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement