1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <iostream>
#include <string>
//#include <stdio.h> // <--- Not needed. C header file for I/O. Covered with "iostream". Pluss there is not C I/O code in the program.
//#include <cstdlib> // <--- Not needed. Maybe later.
//using namespace std; // <--- Best not to use.
// The most recent post that is worth reading. http://www.cplusplus.com/forum/beginner/258335/
// An alternative.
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main(/*int argc, char** argv*/) // <--- If you are not going to use them you do not need them.
{
// <--- Numbers used to initialize the variables only. They have no real use.
int nome1{ 1 }, nome2{ 2 }, nome3{ 3 }, nome4{ 4 }, nome5{ 5 }; // <--- Variables need to be initialized. Variaveis precisam ser inicializadas.
int opcao;
int award1{ 1 }, award2{ 1 }, award3{ 1 }, award4{ 1 }, award5{ 1 }; // <--- Variables need to be initialized. Variaveis precisam ser inicializadas.
double media;
int nomeacoes[5] = { nome1, nome2, nome2, nome4, nome5 }; // <--- Changed.
int premios[5] = { award1, award2, award3, award4, award5 }; // <--- Changed.
char filmes[5][30] = { "star wars", "star treck", "avatar", "home alone", "et" }; // <--- Should be a std::string.
//cout << "menu" << endl;
//cout << "opcao 1-Introduzir o numero de nomeacoes e premios de cada filme" << endl;
//cout << "opcao 2-Calcular o filme com mais nomeacoes" << endl;
//cout << "opcao 3-Calcular a media de premios obtidos" << endl;
//cout << "opcao 4-Sair" << endl;
// Or, you may find that this works better. Ou, voce pode achar que isso funciona melhor.
cout
<< "\n" << string(25, ' ') << "MENU\n\n" // <--- Creates 25 spaces.
<< "opcao 1-Introduzir o numero de nomeações e premios de cada filme\n"
<< "opcao 2-Calcular o filme com mais nomeacoes\n"
<< "opcao 3-Calcular a media de prémios obtidos\n"
<< "opcao 4-Sair\n"
<< "Enter Choice: ";
cin >> opcao;
if (opcao == 1)
{
cout << "intruduza o numero de nomeaçoes e premios de cada filme\n"; // <--- Changed.
cout << filmes[0] << endl; // <--- Changed.
cout << filmes[1] << endl;
cout << filmes[2] << endl;
cout << filmes[3] << endl;
cout << filmes[4] << endl;
// <--- Could use.
//cout
// << filmes[0] << '\n'
// << filmes[1] << '\n'
// << filmes[2] << '\n'
// << filmes[3] << '\n'
// << filmes[4] << '\n';
// <--- All these need a prompt to know what to enter. Tudo isso precisa de um prompt para saber no que inserir.
cin >> nome1;
cin >> nome2;
cin >> nome2;
cin >> nome4;
cin >> nome5;
cin >> award1;
cin >> award2;
cin >> award3;
cin >> award4;
cin >> award5;
//cout << "opcao 5-voltar ao menu"; // <--- Needs to be in a loop to make use of this and it is not needed here. Precisa estar em um loop para fazer uso disso e nao e necessário aqui.
//cin >> opcao;
}
|