代码如下:
#include <iostream>
#include <iomanip>
using namespace std;int main()
{cout << setw(15)<<std::left<<"unsigned int" << setw(15) << std::left<<sizeof(unsigned) << endl;cout << setw(15) << std::left << "int" << setw(15) << std::left << sizeof(int) << endl;cout << setw(15) << std::right<< "unsigned int" << setw(15) << std::right << sizeof(unsigned) << endl;cout << setw(15) << std::right << "int" << setw(15) << std::right << sizeof(int) << endl;return 0;
}
测试结果: