Hejj, nie działa mi program w cpp , wie ktoś co jest nie tak ? Będę bardzo wdzięczy za poprawienie :) ponieważ nie ogarniam jeszcze cpp tak dobrze.
#include <iostream>
using namespace std;
srand(time(NULL));
cout<<"Zad 1"<<endl;
int tabA[7];
for(int i = 0; i < 7; i++) {
tabA[i] = (rand() % 9) + 1;
cout<<tabA[i]<<" ";
}
cout<<endl;
int tabB[7];
int tabBMin;
for(int i = 0; i < 7; i++) {
if(tabA[i] % 2 == 0) continue;
tabB[i] = tabA[i];
if(i == 0 || tabBMin > tabB[i]) tabBMin = tabB[i];
cout<<tabB[i]<<" ";
}
cout<<endl<<"Zad 2"<<endl;
cout<<tabBMin<<endl;
for(int i = 0; i < 7; i++) {
cout<<i + 1<<": "<<tabA[i]<<endl;
}
cout<<"Zad 3"<<endl;
int tabC[4][4];
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
tabC[i][j] = (rand() % 9) + 1;
cout<<tabC[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
int tabCMin;
for(int i = 0; i < 4; i++) {
int sum = 0;
for(int j = 0; j < 4; j++) {
sum += tabC[i][j];
}
if(i == 0 || tabCMin > sum) tabCMin = sum;
cout<<sum<<endl;
}
cout<<endl<<tabCMin<<endl;
cout<<"Zad 4"<<endl;
int tabAMax;
for(int i = 0; i < 7; i++) {
if(i == 0 || tabAMax < tabA[i]) tabAMax = tabA[i];
}
for(int i = 0; i < 7; i++) {
if(tabA[i] == tabAMax) cout<<i<<": "<<tabA[i]<<endl;
}