Jump to content
Fórum Script Brasil
  • 0

Programa C++ Intermediario


mathheusbueno
 Share

Question

2 answers to this question

Recommended Posts

  • 0

#include<iostream>
#define TAM 9
using namespace std;
int main(){
    int aux;
    int num[10];
    for(int i=0;i<=TAM;i++){
        cout<<"Informe o numero da posição "<<i+1<<" do vetor: ";
        cin>>num;
    }
    for(int i=0;i<=TAM;i++){
        for(int j=0;j<=TAM;j++){
            if(num<num[j]){
                aux=num;
                num=num[j];
                num[j]=aux;
            }
        }
    }
    cout<<"Menor: "<<num[TAM-TAM];
    cout<<"Maior: "<<num[TAM];
    cout<<"Intermediario: "<<num[TAM/2];
    
}
        


acredito que isso resolva mas não tenho ctz

Link to comment
Share on other sites

  • 0
#include <iostream>

using namespace std;

int main()

{

int numeros [10];

int i, p, backup;

    for (i=; i<10; i++)

        {

        cout << "Digite o numero de posicao " << i+1 << ": "<< endl;

        cin >> numeros[i];

        }

    for (i=; i<10; i++)

        {

            for (p=i+1; p<10; p++)

                {

                    if (numeros[i]>numeros[p])

                        {

                        backup = numeros[i];

                        numeros[i] = numeros[p];

                        numeros[p] = backup;

                        p = i;

                        }

                }

        }

    cout << "\nNumero maior: " << numeros[9] << endl;
    cout << "Numero menor: " << numeros[] << endl;
    cout << "Numero intermediario: " << numeros [(10/2)-1]<< endl;

return ;

}


 

Ocorreu erro na hora da postagem, o certo é:

 

  cout << "Numero menor: " << numeros[] << endl;

 

numeros[0].

 

O code está bugando adm. Abraços.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.1k
×
×
  • Create New...