I already wrote a question on this topic, but a new problem appeared.
It seems I do something wrong. This program is a task of a workshop. What I wrote works correctly, the dictionary turns over.
Here is the code:
# include & lt; iostream & gt;
# INCLUDE & LT; String & GT;
# INCLUDE & LT; MAP & GT;
Using Namespace STD;
Map & LT; String, String & GT; BuildReversedMap (Const Map & Lt; String, String & GT; & amp; m) {
// ...
Map & LT; String, String & GT; Newmap;
For (Const Auto & Amp; [Key, Value]: M)
{
NEWMAP [KEY] = VALUE;
}
Return newmap;
}
Map & LT; String, String & GT; G = {{"Cat", "Felis Catus"}, {"Dog", "CANIS LUPUS"}};
INT MAIN ()
{
For (Const Auto & Amp; [Key1, Value1]: BuildReversedMap (G))
COUT & LT; & LT; "{" S & LT; & lt; Value1 & lt; & lt; "," & lt; & lt; key1 & lt; & lt; "}," s;
Return 0;
}
But in response I get it:
Task passed 2/4 checks
Possible problems:
- Your function incorrectly draws the dictionary
I confuse something or isn’t it in the dictionary?
Answer 1, Authority 100%
# include & lt; iostream & gt;
# INCLUDE & LT; String & GT;
# INCLUDE & LT; MAP & GT;
Using Namespace STD;
Map & LT; String, String & GT; BuildReversedMap (Const Map & Lt; String, String & GT; & amp; m) {
// ...
Map & LT; String, String & GT; Newmap;
For (Const Auto & Amp; [Key, Value]: M)
{
Newmap [Value] = Key;
}
Return newmap;
}
Map & LT; String, String & GT; G = {{"Cat", "Felis Catus"}, {"Dog", "CANIS LUPUS"}};
INT MAIN ()
{
For (Const Auto & Amp; [Key1, Value1]: BuildReversedMap (G))
cout & lt; & lt; "{" s & lt; & lt; key1 & lt; & lt; "," & lt; & lt; value1 & lt; & lt; "}," s;
Return 0;
}