my Question Is:


Design And Implement A Programme That Helps To Analyse The Flow Of Patients Into The Emergency Room. Enter The Integers That Represents The Number Of Patients That Entered The Emergency Room During Each Hour Of The Day For Four Weeks In A Three-dimensional Array Then Analyze The Data To
1)obtain The Total Num Of Patience Who Have Entered The Room In The Four Week Period
2) Identfy The Week With The Largest Number Of Patience
3) Identfy The Hour Which There Were The Least Number Of Patients In The Four Week Period
4)identfy The Busiest Four Days Of The Week Period.

Dani AI

Generated

A compact, practical approach and a minimal C++ implementation to turn the 3D data into the requested answers. Treat the dataset as weeks x days x hours (4 x 7 x 24). The steps are: read the 672 integers, compute the overall total, compute per-week totals to find the busiest week, compute per-hour totals across the whole period to find the least-busy hour, and compute per-day totals so the four busiest days can be found. "Busiest four days" is ambiguous; below the code shows both (a) the top 4 individual days and (b) the busiest consecutive 4-day window.

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    const int W = 4, D = 7, H = 24;
    vector<vector<vector<long long>>> a(W, vector<vector<long long>>(D, vector<long long>(H)));
    for (int w=0; w<W; ++w)
      for (int d=0; d<D; ++d)
        for (int h=0; h<H; ++h)
          if (!(cin >> a[w][d][h])) return 0;

    long long total = 0;
    vector<long long> weekTotal(W,0), hourTotal(H,0), dayTotal; dayTotal.reserve(W*D);

    for (int w=0; w<W; ++w) {
      long long wt = 0;
      for (int d=0; d<D; ++d) {
        long long dt = 0;
        for (int h=0; h<H; ++h) {
          long long v = a[w][d][h];
          total += v; wt += v; dt += v; hourTotal[h] += v;
        }
        dayTotal.push_back(dt);
      }
      weekTotal[w] = wt;
    }

    int busiestWeek = max_element(weekTotal.begin(), weekTotal.end()) - weekTotal.begin();
    int leastHour = min_element(hourTotal.begin(), hourTotal.end()) - hourTotal.begin();

    // top 4 individual days
    vector<pair<long long,int>> days;
    for (int i=0;i<(int)dayTotal.size();++i) days.emplace_back(dayTotal[i], i);
    sort(days.begin(), days.end(), greater<>());

    // best consecutive 4-day window
    long long bestWindow = -1; int bestStart = 0;
    long long ws = 0;
    for (int i=0;i<4 && i<(int)dayTotal.size(); ++i) ws += dayTotal[i];
    bestWindow = ws;
    for (int i=4;i<(int)dayTotal.size(); ++i) {
      ws += dayTotal[i] - dayTotal[i-4];
      if (ws > bestWindow) { bestWindow = ws; bestStart = i-3; }
    }

    cout << "Total patients: " << total << "\n";
    cout << "Busiest week: " << (busiestWeek+1) << " (" << weekTotal[busiestWeek] << ")\n";
    cout << "Least-busy hour (0-23): " << leastHour << " (" << hourTotal[leastHour] << ")\n";
    cout << "Top 4 days (dayIndex,patients): ";
    for (int i=0;i<4 && i<(int)days.size();++i) cout << "(" << days[i].second+1 << "," << days[i].first << ") ";
    cout << "\nBest consecutive 4-day window starts at dayIndex " << bestStart+1 << " sum=" << bestWindow << "\n";
}

Notes and cautions: map a flattened day index back via week = idx/7, dayOfWeek = idx%7. Use long long for sums to avoid overflow. Validate input (non-negative integers) and test with small, known data. As and suggested, supply attempted code next time for faster, more focused help; this snippet is ready to compile and adapt.

Recommended Answers

All 6 Replies

hy !!I ope yu r woking hard to help me out. I tried all i could but couldn't get an far. I need help please

hy !!I ope yu r woking hard to help me out. I tried all i could but couldn't get an far. I need help please

Yeah, I'm sure most of us are just about done with your homework.

> Please help me out, I realy need help in the next 4 hours
> 8 Hours Ago
Oh well.

Here's a tip - email yourself a message to a week ago, when we could have done something useful in helping you to work through the problem yourself.

Your "hail mary" pass in the dying seconds of the game just bounced out of the end zone - game over, take your 'F'.

http://www.catb.org/~esr/faqs/smart-questions.html#urgent
http://www.catb.org/~esr/faqs/smart-questions.html#writewell

if yu jus dont want, dont!!!. whats so special about getting an F.

No one is here to do your homework for you. YOU have to be the one to put forth some effort to show that you really want to learn. If people type your codes iin for you, then you'd never learn C++.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.