program :
#include <iostream>
using namespace std;
void calcMax(int** accidentData){
int max = 0;
int maxCount = 0;
for(int i = 0; i<3;i++){
int count = 0;
for(int j = 0; j<4; j++){
count+= *(*(accidentData+i)+j);
}
if(count>maxCount){
max = i;
maxCount = count;
}
}
cout<<"city "<<max+1<<" has most number of
accidents";
cout<<" with a tolal of "<<maxCount<<" accidents
in july\n";
}
int main(){
int* accidentData[3];
for(int i = 0; i<3; i++){
accidentData[i] = new int[4];
cout<<"Enter city"<<i+1<<" information\n";
for(int j = 0; j<4; j++){
cout<<"Week "<<j+1<<" ";
cin>>accidentData[i][j];
}
}
calcMax(accidentData);
return 0;
}
output:
Get Answers For Free
Most questions answered within 1 hours.