zoukankan      html  css  js  c++  java
  • 「Luogu2264」情书

    传送门
    Luogu

    解题思路

    字符串模拟SB题,STL随便搞。
    详情见代码。

    细节注意事项

    • STL总得会吧。

    参考代码

    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cctype>
    #include <cmath>
    #include <ctime>
    #include <string>
    #include <set>
    #define rg register
    using namespace std;
    
    set < string > s1, s2;
    
    int main() {
    #ifndef ONLINE_JUDGE
    	freopen("cpp.in", "r", stdin);
    	freopen("cpp.out", "w", stdout);
    #endif
    	int n; cin >> n;
    	string a;
    	for (rg int i = 1; i <= n; ++i) {
    		cin >> a;
    		for (rg int x = 0; x < a.size(); ++x) a[x] = tolower(a[x]);
    		s1.insert(a);
    	}
    	char c = getchar();
    	a.clear();
    	int ans = 0;
    	while ((c = getchar()) != EOF) {
    		if (c == '
    ') break;
    		if (isalpha(c)) a += tolower(c);
    		else {
    			if (!a.empty()) {
    				if (s1.count(a)) s2.insert(a); a.clear();
    			}
    			if (c == '.') ans += s2.size(), s2.clear();
    		}
    	}
    	cout << ans << endl;
    	return 0;
    }
    

    完结撒花 (qwq)

  • 相关阅读:
    滑动条使用
    jquery日历练习
    JQuery 教程
    JS获取各种宽度、高度的简单介绍
    如何获取元素位置
    DOM练习
    DOM
    函数
    假期练习
    Uva 253 Cube painting
  • 原文地址:https://www.cnblogs.com/zsbzsb/p/11805597.html
Copyright © 2011-2022 走看看