Advertisement
Montoya-Romina-Anahi

Tp4_Punto5_Principal

Jul 7th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //ALGORITMO PRINCIPAL//
  2.  
  3. using System;
  4.  
  5. using System.Collections.Generic;
  6.  
  7. using System.Linq;
  8.  
  9. using System.Text;
  10.  
  11. using System.Threading.Tasks;
  12. namespace ConsoleApp6
  13. {
  14. class Program
  15. {
  16. static void Main(string[] args)
  17. {
  18. List<int> numeros = new List<int>();
  19. List<int> numeromultiplos = new List<int>();
  20. Random random = new Random();
  21. string resp;
  22. Console.WriteLine(" NUMEROS MULTIPLOS DE 2 y 5 ");
  23. do
  24. {
  25. Console.WriteLine(" CUANTOS NUMERO VA CARGAR EN LA LISTA?");
  26. int N = int.Parse(Console.ReadLine());
  27. Console.WriteLine("");
  28. for (int i = 0; i < N; i++)
  29.  
  30. {
  31. int num = random.Next(1, 101);
  32. numeros.AddFirst(num);
  33. }
  34. Console.Write(" NUMERO ALEATORIO:");
  35.  
  36. foreach (int n in numeros)
  37. {
  38. Console.Write(" {0} ", n);
  39. }
  40. foreach (int n in numeros)
  41.  
  42. {
  43. if (n % 2 == 0) && (n % 5 == 0)
  44.  
  45. {
  46. numeromultiplos.AddInOrder(n);
  47.  
  48. }
  49. }
  50.  
  51. Console.WriteLine("");
  52.  
  53. Console.Write("NUMEROS MULTIPLOS DE 2 y 5");
  54.  
  55. Console.WriteLine("");
  56.  
  57. foreach (int n in numeromultiplos)
  58. {
  59. Console.Write(" {0} ", n);
  60. }
  61.  
  62. Console.WriteLine("");
  63.  
  64. Console.WriteLine("DESEA INICIAR DE NUEVO? S/N");
  65.  
  66. resp = Console.ReadLine();
  67.  
  68. } while (resp != "N" && resp != "no");
  69.  
  70. Console.ReadKey();
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement