汉字统计
来源:互联网 发布:手机淘宝如何重新登录 编辑:程序博客网 时间:2024/06/05 17:00
汉字统计
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45292 Accepted Submission(s): 24707
Problem Description
统计给定文本文件中汉字的个数。
Input
输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本。
Output
对于每一段文本,输出其中的汉字的个数,每个测试实例的输出占一行。
[Hint:]从汉字机内码的特点考虑~
[Hint:]从汉字机内码的特点考虑~
Sample Input
2WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa!马上就要期末考试了Are you ready?
Sample Output
149
Author
lcy
Source
C语言程序设计练习(五)
Recommend
lcy | We have carefully selected several similar problems for you: 2048 2046 2049 2047 1002
////// 汉字的内码是负的,一个汉字占两个字节(汉字机内码在计算机的表达方式的描述是,使用二个字节,每个字节最高位一位为1。//计算机中, 补码第一位是符号位, 1 表示为 负数,//所以 汉字机内码的每个字节表示的十进制数都是负数//统计输入字符串含有几个汉字,只只需求出字符串中小于0的字符有几个,将它除以2就得到答案)#include<iostream>#include<cstdlib>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<cstdlib>#include <set>#include<algorithm>#include <limits.h>#include <ctype.h>#include <map>#include <stack>#include <sstream>typedef long long LL;using namespace std;const int N = 105;int data[N][N];int dp[N][N];char c[100][100] = {' '};#define PI 3.1415926void fun() { data[0][0] = 1; data[1][0] = 1; data[1][1] = 1; for(int i = 2; i <= 30; i++) { for(int j = 0; j <= i; j++) { if(j == 0 || j == i) data[i][j] = 1; else data[i][j] = data[i - 1][j - 1] + data[i - 1][j]; } }// for(int i = 0; i <= 30; i++){// for(int j = 0; j <= i; j++){// cout << data[i][j] << " ";// }// cout << endl;// }}int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; char x[1000]; scanf("%d", &n); getchar(); for(int i = 0; i < n; i++){ gets(x); int a = 0; int t = strlen(x); for(int j = 0; j < t; j++){ if(x[j] < 0){ a++; } } printf("%d\n", a / 2); } return 0;}
0 0
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 统计汉字
- 汉字统计
- 汉字统计
- 汉字统计
- 统计汉字
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- 汉字统计
- Spreadsheet Tracking
- 运算符重载
- 命令行压缩jar包cvfm和cvfe
- C/C++中Sqlite使用简介
- TSVD截断奇异值分解
- 汉字统计
- HDU 3507 DP斜率优化 解题报告
- 驱动程序直接编译进内核
- A. 拼音魔法 大学生程序设计邀请赛(华东师范大学)
- 刷清橙OJ--A1014.进制转换5
- 适配器模式
- 人见人爱A^B
- 5、HotSpot的算法实现
- 标签中onclick绑定函数却is not defined的原因