非专业程序员

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2008年11月28日

摘要: 我也是在看了N长时间的C++ Primer之后,发现没有控制cout cin等格式,于在网上查了一下原来是这样:格式控制的头文件为:#include <iomanip>格式如下:1 数字进制:使用hex、dec、oct控制输出数字的进制2 如何对齐:使用setw控制宽度3 设置精度:使用setprecision控制输出精度4 填充字符:使用setfill控制填充字符5 控制格式:使用setioflags(ios_base::fmtflags mask)来控制常用的有ios::fixed固定的浮点显示ios::scientific指数表示ios::left / ios::right 阅读全文
posted @ 2008-11-28 22:57 曲仁岗 阅读(181) 评论(0) 推荐(0) 编辑

摘要: #include<iostream> #include<string> #include<utility> #include<vector> usingnamespacestd;intmain(intargc,char**argv){pair<string,int>user;vector<pair<string,int>>users;while(cin>>user.first>>user.second){users.push_back(user);}for(vector<pair& 阅读全文
posted @ 2008-11-28 22:26 曲仁岗 阅读(160) 评论(0) 推荐(0) 编辑

摘要: #include <iostream>#include <vector>#include <list>#include <string>#include <algorithm>using namespace std;string greet(string form ,string lastname,string title, string::size_type pos,int length){form.replace(8,lastname.length(),lastname);form.replace(5,2,title,5,leng 阅读全文
posted @ 2008-11-28 11:39 曲仁岗 阅读(196) 评论(0) 推荐(0) 编辑