|
안녕하세요. heredity입니다.
질문하신 내용은 Borland C++ Builder에서도 잘 된답니다.
File / New Menu을 누르면 나타나는 New Items Dialog Box에서
New Tab내 Console Wizerd를 선택한 후 ...
편집할 수 있는 상태가 되면 아래 코드를 입력하심 됩니다.
참고로 아래 코드는 도움말에 있는 코드입니다. -.-;;
행복하세요.
//---------------------------------------------------------------------------
#include <vcl.h>
#include <iostream>
#include <iomanip>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
using namespace std;
int i;
float f;
// read an integer and a float from stdin
cin >> i >> f;
// output the integer and goes at the line
cout << i << endl;
// output the float and goes at the line
cout << f << endl;
// output i in hexa
cout << hex << i << endl;
// output i in octal and then in decimal
cout << oct << i << dec << i << endl;
// output i preceded by its sign
cout << showpos << i << endl;
// output i in hexa
cout << setbase(16) << i << endl;
// output i in dec and pad to the left with character
// @ until a width of 20
// if you input 45 it outputs 45@@@@@@@@@@@@@@@@@@
cout << setfill('@') << setw(20) << left << dec << i;
cout << endl;
// output the same result as the code just above
// but uses member functions rather than manipulators
cout.fill('@');
cout.width(20);
cout.setf(ios_base::left, ios_base::adjustfield);
cout.setf(ios_base::dec, ios_base::basefield);
cout << i << endl;
// outputs f in scientific notation with
// a precision of 10 digits
cout << scientific << setprecision(10) << f << endl;
// change the precision to 6 digits
// equivalents to cout << setprecision(6);
cout.precision(6);
// output f and goes back to fixed notation
cout << f << fixed << endl;
return 0;
}
|