حاولت آحل السؤال بس عندي errors و ماعرف آساوي ال output بل setw ممكن المساعده.
Write a C++ program that asks the user to enter temperatures of every day of the week for a three week period and stores them in a Two-Dimensional array named "temp" of size 3X7( The Two-Dimensional array should be dynamically created using dynamic arrays).
The program should find and print the following:
[*=left]The average temperature of each week
[*=left]The maximum temperature that occurred in the three weeks
[*=left]The day and week in which the maximum temperature occurred.
The program run should be as follows:
PROGRAM RUN
[TABLE="width: 522, align: center"]
[TR]
[TD="colspan: 10, align: left"]Enter the temperatures of week 1: 27 28 28 29 30 31 32
Enter the temperatures of week 2: 33 34 35 36 37 38 39
Enter the temperatures of week 3: 39 40 39 38 36 35 34
[/TD]
[/TR]
[TR]
[TD="align: left"]Day[/TD]
[TD="align: left"][/TD]
[TD="align: left"]1[/TD]
[TD="align: left"]2[/TD]
[TD="align: left"]3[/TD]
[TD="align: left"]4[/TD]
[TD="align: left"]5[/TD]
[TD="align: left"]6[/TD]
[TD="align: left"]7[/TD]
[TD="align: left"]Average[/TD]
[/TR]
[TR]
[TD="align: left"]Week[/TD]
[TD="align: left"]1[/TD]
[TD="align: left"]27[/TD]
[TD="align: left"]28[/TD]
[TD="align: left"]28[/TD]
[TD="align: left"]29[/TD]
[TD="align: left"]30[/TD]
[TD="align: left"]31[/TD]
[TD="align: left"]32[/TD]
[TD="align: left"]29.2857[/TD]
[/TR]
[TR]
[TD="align: left"]Week[/TD]
[TD="align: left"]2[/TD]
[TD="align: left"]33[/TD]
[TD="align: left"]34[/TD]
[TD="align: left"]35[/TD]
[TD="align: left"]36[/TD]
[TD="align: left"]37[/TD]
[TD="align: left"]38[/TD]
[TD="align: left"]39[/TD]
[TD="align: left"]36.0000[/TD]
[/TR]
[TR]
[TD="align: left"]Week[/TD]
[TD="align: left"]3[/TD]
[TD="align: left"]39[/TD]
[TD="align: left"]40[/TD]
[TD="align: left"]39[/TD]
[TD="align: left"]38[/TD]
[TD="align: left"]36[/TD]
[TD="align: left"]35[/TD]
[TD="align: left"]34[/TD]
[TD="align: left"]37.2857[/TD]
[/TR]
[TR]
[TD="colspan: 10, align: left"]The maximumtemperature is 40 occurred in week 3 and day .
كود:
#include <iostream>
using namespace std;
int main()
{
int * temp[3];
int max=0
for(int i=0; i<3;i++)
temp[i]=new int[7];
for(int i=0; i<3; i++)
cout<<"Enter the temperatures of week "<<i+1<<":";
for(int j=0; j<7; j++)
cin>>temp[i][j];
sum+=temp[j];
avg=(sum/7);
for(int k=0; k<j; k++)
if(temp[max]<temp[j])
max=j;
cout<<"The maximumtemperature is "<<max<<" occurred in week "<<temp[i]<<endl;
}
[/TD]
[/TR]
[/TABLE]