hdu 3753 字符串 Alignment of Code
2012-09-14 19:35
323 查看
http://acm.hdu.edu.cn/showproblem.php?pid=3753
题意: 就是让你把一些字符串相应的单词对齐输出。呵呵,学到了一些stl的东西、
可是,时间为什么过得这么快呢?
getline(cin,tmp)
istringstream strin(tmp);
while(strin >> tmp)
cout << setiosflags(ios :: left);
cout << setw(len[j] + 1) << str[i][j];
题意: 就是让你把一些字符串相应的单词对齐输出。呵呵,学到了一些stl的东西、
可是,时间为什么过得这么快呢?
getline(cin,tmp)
istringstream strin(tmp);
while(strin >> tmp)
cout << setiosflags(ios :: left);
cout << setw(len[j] + 1) << str[i][j];
/* Pro: 0 Sol: date: */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <iomanip>//header #include <cmath> #include <sstream>//header #include <queue> #include <set> #include <vector> //istringstream对象可以绑定一行字符串,然后以空格为分隔符把该行分隔开来。 using namespace std; string tmp,str[1111][190]; int len[190],T,num[1111]; int main(){ scanf("%d",&T); while(T --){ memset(len,0,sizeof(len)); memset(num,0,sizeof(num)); int nNum = 0; while(getline(cin,tmp) && tmp != "@"){ if(tmp == "") continue; //empty istringstream strin(tmp); int j = 0; nNum ++; while(strin >> tmp){ str[nNum][++ j] = tmp; if(tmp.size() > len[j]) len[j]= tmp.size(); } num[nNum] = j; } cout << setiosflags(ios :: left); for(int i = 1; i <= nNum; i ++){ for(int j = 1; j < num[i]; j ++){ cout << setw(len[j] + 1) << str[i][j]; } cout << str[i][num[i]] << endl; } } return 0; }
相关文章推荐
- hdu 3753 Alignment of Code
- Alignment of Code(hdu)
- UVa 1593 Alignment of Code(字符串)
- HDU 3753 Alignment of Code 字符串对其 stl
- HDU 3753 Alignment of Code 字符串对其 stl
- 1593 - Alignment of Code
- hdu 1035 (usage of sentinel, proper utilization of switch and goto to make code neat)
- UVa1593 Alignment of Code
- 【习题5-1 UVA - 1593】Alignment of Code
- UVA 1593 Alignment of Code
- UVa 1593 - Alignment of Code
- UVA1593 - Alignment of Code
- UVA 1593 Alignment of Code
- UVa 1593 - Alignment of Code
- Uva Alignment of Code
- UVa 1593 Alignment of Code
- UVa 1593 - Alignment of Code
- UVA 1593 Alignment of Code
- HDU 1483 Automatic Correction of Misspellings (字符串大模拟)
- UVa 1593 - Alignment of Code(格式+细节)