IO-04. Mixed type data format input (5)

Source: Internet
Author: User

IO-04. Mixed type data format input (5) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Joleen (Tsinghua University)

The subject requires a program, sequentially read into the floating-point number 1, Integer, character, floating point number 2, and then by character, Integer, floating-point number 1, floating point number 2 order output.

Input format:

Enter the floating-point number 1, Integer, character, floating-point number 2 in the order given in a row, separated by 1 spaces.

Output format:

Output in a row in the order of characters, integers, floating-point number 1, floating-point number 2, where the floating-point number retains 2 digits after the decimal point.

Input Sample:
2.12 C 4.7
Sample output:
C 88 2.12 4.70
1#include <iostream>2#include <iomanip>3 using namespacestd;4 intMain ()5 {6    intA;7    floatb,c;8    CharD;9Cin>>b>>a>>d>>C;Tencout<<d<<" "<<a<<" " OneCout<<setiosflags (::fixed) <<setprecision (2) <<b<<" " ACout<<setiosflags (::fixed) <<setprecision (2) <<c<<Endl; -    return 0; -}

Operation Result:

a.cpp:in function ' int main () ': a.cpp:11:4: error:expected '; ' Before ' cout '
Solution: A semicolon is added to each line after the cout.
1#include <iostream>2#include <iomanip>3 using namespacestd;4 intMain ()5 {6    intA;7    floatb,c;8    CharD;9Cin>>b>>a>>d>>C;Tencout<<d<<" "<<a<<" "; OneCout<<setiosflags (::fixed) <<setprecision (2) <<b<<" "; ACout<<setiosflags (::fixed) <<setprecision (2) <<c<<Endl; -    return 0; -}

Run Result: Compile error

a.cpp:in function ' int main () ': A.cpp:11:29:error:cannot convert ' std::ios_base& (*) (std::ios_base&) ' to ' std:: Ios_base::fmtflags {aka Std::_ios_fmtflags} ' for argument ' 1 ' to ' Std::_setiosflags std::setiosflags (std::ios_base:: fmtflags) ' A.cpp:12:29:error:cannot convert ' std::ios_base& (*) (std::ios_base&) ' to ' std::ios_base::fmtflags {aka Std::_ios_fmtflags} ' for argument ' 1 ' to ' std::_setiosflags std::setiosflags (std::ios_base::fmtflags) '

Solution: Leak the ios!!!! Ios::fixed

View Submission Evaluation Results
Time Results score Topics language spents (MS) memory (KB) User
December 16 23:25 The answer is correct 5 IO-04 C + + (g++ 4.7.2) 1 368 Liyuhui
Test point
Test Point Results spents (MS) memory (KB) Score/Perfect
0 The answer is correct 1 368 5/5

View Code

IO-04. Mixed type data format input (5)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.