[+] Nauka, banalne zadanie c++
: 30 marca 2010, 15:51
Nie śmiać się bo ja się uczę. Mógłby ktoś to skompilować i powiedzieć mi dlaczego pierwszy model się nie wyświetla? Nie mogę tego zrozumieć.
Kod: Zaznacz cały
#include <iostream>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <climits>
#include <string>
#include <iomanip>
int mygetch(void)
{
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
using namespace std;
int main()
{
char marka[3][10];
char model[3][10];
float poj[3][4];
short max[3][3];
short poj_razem=0;
short max_sr=0;
for(short i=0; i<3; i++)
{
cout<<endl<<"Podaj markę samochodu: ";
cin>>marka[i];
cout<<endl<<"Podaj model samochodu "<<marka[i]<<": ";
cin>>model[i];
cout<<endl<<"Podaj pojemność tego samochodu: ";
cin>>poj[i][4];
cout<<endl<<"Podaj prędkość maksymalną tego samochodu: ";
cin>>max[i][3];
}
for(short i=0; i<3; i++)
{
cout<<endl<<marka[i]<<" "<<model[i]<<" "<<poj[i][4]<<" "<<max[i][3];
}
for(short i=0; i<3; i++)
{
poj_razem+=poj[i][4];
}
for(short i=0; i<3; i++)
{
max_sr+=max[i][3];
}
max_sr/=3;
cout<<endl<<"Łączna pojemność to: "<<poj_razem;
cout<<endl<<"Średnia prędkość to: "<<max_sr;
cout<<endl<<endl;
mygetch();
return 0;
}