HDU 2030漢字統計

2021-08-03 23:44:22 字數 504 閱讀 9643

機內碼:為了避免ascii碼和國標碼同時使用時產生二義性問題,大部分漢字系統都採用將國標碼每個位元組高位置1作為漢字機內碼。

也就是說,乙個漢字字元由兩個位元組組成,而且這兩個位元組的最高位一定是1.

那麼輸入的時候只getchar(),這樣只能一半一半的輸入,也就是乙個漢字分兩次輸入。

而每次輸入的值的首位一定是1,也就是一定是負的。(都知道補碼首位1表示負數吧……)

而其他字元的ascii碼是正的。

#include #include #include #include #include #include #include #include #include #include #include using namespace std;

const int maxn=1000;

const int inf=0x3f3f3f3f;

int main()

printf("%d\n",cnt/2);

}}

HDU 2030 漢字統計

description 統計給定文字檔案中漢字的個數。input 輸入檔案首先包含乙個整數n,表示測試例項的個數,然後是n段文字。output 對於每一段文字,輸出其中的漢字的個數,每個測試例項的輸出佔一行。hint 從漢字機內碼的特點考慮 sample input 2 wahaha wahaha ...

HDU 2030 漢字統計

problem description 統計給定文字檔案中漢字的個數。input 輸入檔案首先包含乙個整數n,表示測試例項的個數,然後是n段文字。output 對於每一段文字,輸出其中的漢字的個數,每個測試例項的輸出佔一行。hint 從漢字機內碼的特點考慮 sample input 2wahaha ...

HDU 2030 漢字統計

time limit 1000 ms memory limit 32768 kb 統計給定文字檔案中漢字的個數。input 輸入檔案首先包含乙個整數n,表示測試例項的個數,然後是n段文字。output 對於每一段文字,輸出其中的漢字的個數,每個測試例項的輸出佔一行。sample input 2 wa...