Jungs können mir helfen, diesen Code zu tun, weil ich 6 Stunden verwendet habe und immer noch nicht die Antwort bekommen.Um zweidimensionales Array zu erstellen
Die Frage ist ", ein Programm schreiben, das eine zweidimensionale Anordnung entsteht (6 * 6), besiedeln das Array mit Zufallszahlen zwischen 1 und 100 a: Erhalten der Summe aller Zahlen b: Erhalten der durchschnittlichen aller Zahlen c: die Zeilensumme d Bestimmen Sie: die höchste in der Reihe e ermitteln. Bestimmen Sie die niedrigste in der Reihe
Hier ist mein Code
#include <iostream>
#include <ctime>
using namespace std;
// Main Function
int main()
{
//Initialize Variables
int table1[6][6];
int highest ;
int lowest ;
double sumRow = 0;
int row = 0;
int col = 0;
//PrintArray
for (row = 0; row < 6; row++)
{
for (col = 0; col < 6; col++)
{
{
table1[row][col] = rand() % 100 + 1;
}
cout << table1[row][col] << "\t";
}
cout << "" << endl << endl;
}
//Highest & lowest value in the row
for(row = 0; row <6; row ++)
{
highest = table1[row][0];
lowest = table1[row][0];
for (col = 0; col < 6; col++)
{
if (highest < table1[row][col])
highest = table1[row][col];
if (lowest > table1[row][col])
lowest = table1[row][col];
sumRow = sumRow + table1[row][col];
}
cout <<" Row" << row <<" highest value :" << highest <<endl;
cout <<" Row" << row <<" lowest value :" << lowest << endl;
cout <<" Row" << row <<" average value :" << sumRow/6 <<endl;
cout <<" Row" << row <<" Total value :" << sumRow << endl;
sumRow = 0;
cout << endl;
}
}
_ "[Ich] bekomme immer noch nicht die Antwort" _ ist keine besonders gute Problembeschreibung. Mit was genau hast du Probleme? – Michael
@ItsGreg 'row = 0' und' col = 0' in Loops dabei, denke ich –
Bitte [editieren] Sie Ihre Frage, um eine [mcve] und eine klare Problemaussage aufzunehmen. –