Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ALGORITMO PRINCIPAL//
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numeros = new List<int>();
- List<int> numeromultiplos = new List<int>();
- Random random = new Random();
- string resp;
- Console.WriteLine(" NUMEROS MULTIPLOS DE 2 y 5 ");
- do
- {
- Console.WriteLine(" CUANTOS NUMERO VA CARGAR EN LA LISTA?");
- int N = int.Parse(Console.ReadLine());
- Console.WriteLine("");
- for (int i = 0; i < N; i++)
- {
- int num = random.Next(1, 101);
- numeros.AddFirst(num);
- }
- Console.Write(" NUMERO ALEATORIO:");
- foreach (int n in numeros)
- {
- Console.Write(" {0} ", n);
- }
- foreach (int n in numeros)
- {
- if (n % 2 == 0) && (n % 5 == 0)
- {
- numeromultiplos.AddInOrder(n);
- }
- }
- Console.WriteLine("");
- Console.Write("NUMEROS MULTIPLOS DE 2 y 5");
- Console.WriteLine("");
- foreach (int n in numeromultiplos)
- {
- Console.Write(" {0} ", n);
- }
- Console.WriteLine("");
- Console.WriteLine("DESEA INICIAR DE NUEVO? S/N");
- resp = Console.ReadLine();
- } while (resp != "N" && resp != "no");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement