Kattis-Alphabet Spam
Posted 做一个AC梦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kattis-Alphabet Spam相关的知识,希望对你有一定的参考价值。
题目所述基本内容
About 90 percent of the 300 billion emails sent every day are spam. Thus, a fast spam detection mechanism is crucial for large email providers. Lots of spammers try to circumvent spam detection by rewriting words like “M0n3y”, “Ca$h”, or “Lo||ery”.
A very simple and fast spam detection mechanism is based on the ratios between whitespace characters, lowercase letters, uppercase letters, and symbols. Symbols are defined as characters that do not fall in one of the first three groups.
输入输出样例
Input
The input consists of:
-
one line with a string consisting of at least 1 and at most 100000 characters.
A preprocessing step has already transformed all whitespace characters to underscores (_), and the line will consist solely of characters with ASCII codes between 33 and 126 (inclusive).
Output
Output four lines, containing the ratios of whitespace characters, lowercase letters, uppercase letters, and symbols (in that order). Your answer should have an absolute or relative error of at most 10−6.
代码
#include <iostream>
#include<string>
using namespace std;
int main()
int i;
string ch;
cin >> ch;
int len = ch.length();
int Capital = 0, lowercase = 0, Symbol= 0, Underline = 0;
for (i = 0; i <= len; i++)
if (ch[i] >= 'A' && ch[i] <= 'Z')
Capital++;
if (ch[i] >= 'a' && ch[i] <= 'z')
lowercase++;
if (ch[i] >= '!' && ch[i] <= '@')
Symbol++;
if (ch[i] >= '[' && ch[i] <= '^')
Symbol++;
if (ch[i] == '`')
Symbol++;
if (ch[i] >= '' && ch[i] <= '~')
Symbol++;
if (ch[i] == '_')
Underline++;
double wh, up, low, sy;
double lenf = (double)len;
wh =(double)Underline / lenf;
up =(double)Capital / lenf;
low =(double)lowercase / lenf;
sy = (double)Symbol / lenf;
printf("%.15lf\\n", wh);
printf("%.15lf\\n", low);
printf("%.15lf\\n", up);
printf("%.15lf\\n", sy);
return 0;
结束语
好兄弟好兄弟,留下你的关注和点赞,666走一波!!!!!
以上是关于Kattis-Alphabet Spam的主要内容,如果未能解决你的问题,请参考以下文章