Suppose you are given some n observations regarding infection from some disease. Each observation consists of two parts: (a) the date on which the observation was made, (b) the number of patients who tested positive. For simplicity we assume that the dates are positive integers. Also assume that any patient is tested at most once. A number D, the maximum number of days that the infection persists, is also given. A main program that gives information about the disease is already typed in (and also visible to you). It first takes as input D, the expected disease duration. Then it takes as input n, the number of observations, then n pairs that give the date (integer), and the number of patients testing positive (integer). This information is to be stored in a struct "Observation" which you are to define. The information is to be read using a member function "read" of Observation struct, which also you must define. Next you are to write a function "uncured" which says how many patients will be uncured on a given date. For simplicity assume that if a group of patients test positive on date i, then they will be reported as uncured only between the dates i (inclusive) and i+D (exclusive). What you write is to be used with the main program which is already typed in. int main(){ int D; cin >> D; int n; cin >> n; Observation observations[n]; for(int i=0; i while(true){ int date; cin >> date; if(date == -1) break; cout << date << " " << uncured(observations, n, D, date) << endl; } }
Answers
tex
huge
bold
/hold
Then it takes as input n, the number of observations, then n pairs that give the date (integer), and the number of patients testing positive (integer). This information is to be stored in a struct "Observation" which you are to define. The information is to be read using a member function "read" of Observation struct, which also you must define. Next you are to write a function "uncured" which says how many patients will be uncured on a given date. For simplicity assume that if a group of patients test positive on date i, then they will be reported as uncured only between the dates i (inclusive) and i+D (exclusive). What you write is to be used with the main program which is already typed in. int main(){ int D; cin >> D; int n; cin >> n; Observation observations[n]; for(int i=0; i while(true){ int date; cin >> date; if(date == -1) break; cout << date << " " << uncured(observations, n, D, date) << endl; } }