Due on 2020-04-08, 23:59 IST
Week 10 Programming Assignment 1
You are required to maintain number of patients infected by corona per country.
You are given data which needs to be updated as and when new data is received.
The input line has two parts
1) string: Country, EXIT is specify end of input.
3) int: count
At the end print count per country (sorted by country name). Following is the sample input and expected output.
Input:
China 10 USA 5 China -5 USA -5 China -5 USA 5 EXIT Output:
China:0 USA:5
Sample Test Cases
Input Output
X
NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » An Introduction To Programming Through C++
(course)
(https://swayam.gov.in)
(https://swayam.gov.in/nc_details/NPTEL)Announcements (announcements)
About the Course (https://swayam.gov.in/nd1_noc20_cs53/preview) Ask a Question (forum) Progress (student/home) Mentor (student/mentor)
Course outline
How does an NPTEL online course work?
Week 0 Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10
Test Case 1
USA 10 Peru 5 USA 120 Spain 20 France 7 Peru 25 India 1 Peru 40 India 2 India 0 EXIT
France:7 India:3 Peru:70 Spain:20 USA:130
Test Case 2
Italy 5 China 100 China -10 Spain 20 France 7 Italy 25 India 20 Italy -20 India -10 India 5 India -5 China 100 Italy 5 China 120 Spain 20 France 7 Italy 25 China -30 India 1 China -30 Italy 40 India 2 China -20 India 0 India -2 Italy -20 China -50 Italy -40 India -1 China 10 USA 5 China -5 USA 5 USA -5 China -5 China 100 Italy 5 China 120 Spain 20 France 7 Italy 25
China:1240 France:82 India:38 Italy:320 Peru:140 Spain:220 USA:275 Lecture 22 :
Representing variable length entities: Part 1 : Introduction (unit?
unit=95&lesson=133) Lecture 22 :
Representing variable length entities: Part 2 : Heap memory basics (unit?
unit=95&lesson=134) Lecture 22 :
Representing variable length entities: Part 3 : Pitfalls of using heap memory (unit?
unit=95&lesson=135) Lecture 22 :
Representing variable length entities: Part 4 : Automating memory management (unit?
unit=95&lesson=136) Lecture 22 :
Representing variable length entities: Part 5 : Implementing a class with automated memory management 1 (unit?
unit=95&lesson=137) Lecture 22 :
Representing variable length entities: Part 6 : Implementing a class with automated memory management 2 (unit?
unit=95&lesson=138) Lecture 22 :
Representing variable length
France 0 Italy 40 France 2 Italy 0 Italy 5 China 100 China -10 Spain 20 France 7 Italy 25 India 20 Italy -20 India -10 India 5 India -5 China 100 Italy 5 China 120 Spain 20 France 7 Italy 25 France 0 Italy 40 France 2 Italy 0 USA 10 Peru 5 USA 120 Spain 20 France 7 Peru 25 France 7 India 1 Peru 40 India 2 India 0 China 10 USA 5 China -5 USA -5 China -5 USA 5 China 100 Italy 5 China 120 Spain 20 France 7 Italy 25 China -30 India 1 China -30 Italy 40 India 2 entities: Part 7
: Using the implemented class and conclusion (unit?
unit=95&lesson=139) Lecture 23 :
The Standard Library: Part 1 : Class string (unit?
unit=95&lesson=140) Lecture 23 :
The Standard Library: Part 2 : Class vector (unit?
unit=95&lesson=141) Lecture 23 :
The Standard Library: Part 3 : Sorting vectors and arrays (unit?
unit=95&lesson=142) Lecture 23 :
The Standard Library: Part 4 : Classes map and
unordered_map (unit?
unit=95&lesson=143) Lecture 23 :
The Standard Library: Part 5 : Iterators (unit?
unit=95&lesson=144) Download
Videos (unit?
unit=95&lesson=186) Weekly
Feedback (unit?
unit=95&lesson=198) Quiz : Week 10 Assignment (assessment?
name=222) Week 10 Programming Assignment 1
China -20 India 0 India -2 Italy -20 China -50 Italy -40 India -1 China 10 USA 5 China -5 USA 5 USA -5 China -5 USA 10 Peru 5 USA 120 Spain 20 Peru 25 India 1 Peru 40 India 2 India 0 China 100 Italy 5 China 120 Spain 20 France 7 Italy 25 India 1 Italy 40 India 2 India 0 Italy 5 Spain 20 France 7 Italy 25 India 1 India 0 Italy 40 India 2 India 0 India -2 China 100 China 120 Spain 20 France 7 India 10 India 0 France 0 India -2 France -4 France 5 EXIT Week 11
Week 12
Text Transcripts
(/noc20_cs53/progassignment?
name=223) Week 10 Programming Assignment 2
(/noc20_cs53/progassignment?
name=224) Week 10 Programming Assignment 3
(/noc20_cs53/progassignment?
name=227)
Test Case 3
Spain 20 France 7 Italy 25 India 20 Italy -20 India -10 India 5 India -5 China 100 EXIT
China:100 France:7 India:10 Italy:5 Spain:20
Test Case 4
China 10 USA 5 China -5 USA -5 China -5 USA 5 EXIT
China:0 USA:5
Test Case 5
Italy 5 China 100 China -10 Spain 20 France 7 Italy 25 India 20 Italy -20 India -10 India 5 India -5 EXIT
China:90 France:7 India:10 Italy:10 Spain:20
Test Case 6
China 100 Italy 5 China 120 Spain 20 France 7 Italy 25 France 0 Italy 40 France 2 Italy 0 EXIT
China:220 France:9 Italy:70 Spain:20
The due date for submitting this assignment has passed.
As per our records you have not submitted this assignment.
Sample solutions (Provided by instructor)
#include <iostream>
#define repeat(x) for(int _iterator_i = 0, _iterator_limit = x; _iterat
#define main_program int main()
#include <cmath>
#include <map>
using namespace std;
i 12 34 56 7
int main(){
map<string, int> m ; while(true){
string country; cin >> country;
if(country == "EXIT") break;
int count; cin >> count;
m[country] = m[country] + count;
} for (auto x : m){
cout << x.first << ":" << x.second << endl;
} } 89 1011 1213 1415 1617 1819