统计字符.txt
来自「浙江大学研究生复试上机题目及解答。欢迎大家下载。」· 文本 代码 · 共 29 行
TXT
29 行
//test
#include <cstdio>
#include <string>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;
int alph[300];
char str[300],str2[300];
void hash() {
int i;
for (i=0;str2[i];i++) {
alph[ str2[i] ] ++;
}
}
int main() {
int i;
while (gets(str)) {
if (str[0] == '#' && str[1] == 0) break;
memset(alph,0,sizeof(alph));
gets(str2);
hash();
for (i=0;str[i];i++) {
printf("%c %d\n",str[i],alph[ str[i] ]);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?