77、78、79

#include <fstream>
#include <strstream>
#include <cstdlib>
using namespace std;
int main(int argc, char* argv[])
{
 
 strstream textfile;
 {
  ifstream in(argv[1]);
        textfile << in.rdbuf();
 }
 ofstream out(argv[2]);
 
 const int bsz = 100;
 char buf[bsz];
 int line = 0;
 while(textfile.getline(buf, bsz)) {
  out.setf(ios::right, ios::adjustfield);
  out.width(1);
  out << ++line << ". " << buf << endl;
 }
 return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;
int main()
{
 locale loc(".936"); //创建本地化配置方案
 wcout.imbue(loc); //为wcout设置编码方案
 wifstream in(L"习题9-10输入.txt"); //创建文件宽输入流
 wofstream out(L"习题9-10输出.txt"); //创建文件宽输入流
 in.imbue(loc);  //为in设置编码方案
 out.imbue(loc);  //为out设置编码方案
 wstring line;  //用来存储一行内容
 map<wchar_t, int> counter;
 
 while(getline(in,line))
 {
  for(int i=0; i<line.length(); ++i)
  {
   counter[line[i]] ++;
  }
 }
 map<wchar_t, int>::iterator itor;
 int i = 1;
 for(itor=counter.begin(); itor != counter.end(); ++itor, ++i)
 {
  out<<itor->first<<"\t"<<itor->second<<"\t";
  if(i%4 == 0)
  {
   out<<endl;
  }
 }
 in.close();
 out.close();
 return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值