标签:style blog http io color ar os sp for
1 #include "../../st.h" 2 3 int main() 4 try{ 5 string s1="a.txt"; 6 string s2="z.txt"; 7 ifstream ifs(s1.c_str()); 8 if(!ifs) 9 error("can not open input file",s1); 10 ofstream ofs(s2.c_str()); 11 if(!ofs) 12 error("can not open output file1",s2); 13 char ch; 14 while(ifs.get(ch)) 15 { 16 if(isalpha(ch)) 17 ch=tolower(ch); 18 ofs<<ch; 19 } 20 keep_window_open(); 21 } 22 catch(exception&e){ 23 cerr<<e.what()<<endl; 24 while(1); 25 return 1; 26 } 27 28 catch(...){ 29 cerr<<"exception\n"; 30 while(1); 31 return 2; 32 } 33
1 int fn() 2 { 3 char c; 4 cin>>c; 5 if(c==‘0‘) 6 { 7 char c1; 8 cin>>c1; 9 if(c1==‘x‘) 10 { 11 cin.putback(c1); 12 cin.putback(c); 13 return 16; 14 } 15 else 16 { 17 cin.putback(c1); 18 cin.putback(c); 19 return 8; 20 } 21 } 22 else 23 { 24 cin.putback(c); 25 return 10; 26 27 } 28 29 } 30 31 int main() 32 { 33 int i; 34 cin.unsetf(ios::hex); 35 cin.unsetf(ios::dec); 36 cin.unsetf(ios::oct); 37 cout<<showbase; 38 int p=fn(); 39 cin>>i; 40 switch (p) 41 { 42 case 16: 43 cout<<hex<<i<<" hexadecimal converts to "<<dec<<i<<" decimal"<<endl; 44 break; 45 case 8: 46 cout<<oct<<i<<" octmal converts to "<<dec<<i<<" decimal"<<endl; 47 break; 48 case 10: 49 cout<<dec<<i<<" decimal converts to "<<dec<<i<<" decimal"<<endl; 50 break; 51 default: 52 break; 53 } 54 while(1); 55 return 0; 56 57 }
习题14
<<scientific<<setprecision(8)<<setw(20)
用for控制域数 每四个一行
习题15
排序比较难 先存后排序 再计数
标签:style blog http io color ar os sp for
原文地址:http://www.cnblogs.com/yueba/p/4088422.html