블로그 이미지
송시혁

calendar

1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive

2013. 11. 11. 19:13 c++

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  int a=1234;
  
  cout << "a= " << a << endl;    //a의 값 출력
  cout << "a= " << setw(5<< a << endl;  //출력폭이 5이므로 빈칸까지 출력
  cout << "a= " << hex << setw(5<<<< endl;//헥사값으로 빈칸까지 출력.
  cout << "a= " << dec << setw(5<<<< endl;//10진수로 빈칸까지 출겨하여 5자리 맞춤.

  double b=45.8769;
  
  cout << "b= " << b << endl;//45.8769출력.
  cout << "b= " << fixed << b << endl;//실수형을 본래 형태로 출력.

  cout << "b= " << setprecision(0<< b << endl;
  //소수점 이하 자리수. 0으로 설정하면 자연수만 나온다. 단, 반올림한다.

  double c = 123;

  cout << "c= " << c << endl;//123출력
  cout << "c= " << setprecision(0<<  c << endl;//자연수 123출력
  cout << "c= " << showpoint << c << endl;
  //소수점 출력. 여기서는 소수점이 없기 때문에 .만 출력
  //반드시 출력.
  cout << 987.0 << endl;
  
  

  return 0;
}


posted by 송시혁