Informática, perguntado por ellenmelogomes4751, 11 meses atrás

Escreva um programa que leia um vetor de 50 posições de números inteiros e mostre somente os positivos

Soluções para a tarefa

Respondido por mifihakejo
0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Brainly2 {

   class Program {

       static void Main(string[] args) {

           Random random = new Random();

           int[] vetor = new int[50];

           for (int i = 0; i < vetor.Length; i++) {

               vetor[i] = random.Next(-50, 50);

           }

           for (int i = 0; i < vetor.Length; i++) {

               bool isPositive = vetor[i] > 0;

               if (isPositive) {

                   Console.WriteLine(vetor[i]);

               }

           }

       }

   }

}


Perguntas interessantes