首页 > 其他 > 详细

bjfu1299 stl使用

时间:2015-03-27 06:22:21      阅读:130      评论:0      收藏:0      [点我收藏+]

题目超简单,我写解题报告是因为我的代码用了些STL,使代码很简洁。

*
 * Author    : ben
 */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
inline bool isletter(char c) {
    return !isalpha(c) && c != 0;
}

int main() {
    int T, cn;
    char str[100];
    scanf("%d", &T);
    for (int t = 1; t <= T; t++) {
        scanf("%s", str);
        remove_if(str, str + strlen(str) + 1, isletter);
        transform(str, str + strlen(str), str, ::tolower);//加::是为防止重载的函数冲突,有别的写法
        str[0] = toupper(str[0]);
        printf("Case #%d: %s\n", t, str);
    }
    return 0;
}

看起来有点像装b,其实真不是。stl用熟以后真能很省代码,这是我11年看到大神watashi的超简练代码后的感悟,努力追之。

 

bjfu1299 stl使用

原文:http://www.cnblogs.com/moonbay/p/4370569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!