Programming problem solving tutorialInput/Output with C++/Java 5For most of the problems you will be required to read some data from the standard input (keyboard) and write your answers to the standard output (console). It's important to follow the input/output specifications EXACTLY. If your output is different from the correct by a single white space your solution will not be counted as ACCEPTED and you will be penalized. C++ cin/coutIf this is your first programming contest and you have decided to use C++, it is highly recommended that you use cin/cout for input and output. You will need to add the lines: #include <iostream> #include <string> #include <other_stuff> using namespace std;at the top of your program to be able to use cin/cout. Supposing you wanted to read an integer, a char and a word in, then the next line, you could do the following: int d; char c; string s1, s2; cin >> d >> c >> s1; getline(cin, s2); getline(cin, s2);Note the first getline is necessary to ignore the rest of the first line, even if it's empty. Supposing you wanted to print them back out: cout << d << " " << c << " " << s1 << endl << s2 << endl;See examples below. Java Scanner/System.outIt's recommended that you use the Scanner class to do input with Java 5. You will need to add: import java.util.*; import java.io.*;to the start of your code. Before reading input with Java 5 you will need to create a Scanner object by adding the line Scanner in = new Scanner(System.in);to your main method. Supposing you wanted to read an integer, a char and a word in, then the next line, you could do the following: int d = in.nextInt(); char c = in.next().charAt(0); s1 = in.next(); in.nextLine(); s2 = in.nextLine();Note the first nextLine is necessary to ignore the rest of the first line, even if it's empty. Supposing you wanted to print them back out: System.out.println(d + " " + c + " " + s1); System.out.println(s2);Use System.out.print("Blah") to avoid printing a newline. See examples below. Examples of complete C++/Java programs that: Read a pair integers, n and m from the input until the end of file and print the sum of each pair on a single line: example.cpp / example.javaRead strings (words) until end of file and print the last letter of every string (word) on a single line: example_str.cpp / example_str.javaRead integers from input until EOF and print the last two digits of each integer on a single line, separated by space: last_digs.cpp / last_digs.javaRead integers from input until EOF. For each number, print the number divided by 7 to two significant digits. Each of those should be printed on its own line, and there should be a blank line between outputs: div_seven.cpp / div_seven.javaIt's highly recommended that you always compile your C++ programs with the -Wall flag. It will print some extra warnings. For example, example.cpp can be compiled by typing:g++ example.cpp -Wall |