L1-017. 到底有多二 C語言
阿新 • • 發佈:2019-02-04
一個整數“犯二的程度”定義為該數字中包含2的個數與其位數的比值。如果這個數是負數,則程度增加0.5倍;如果還是個偶數,則再增加1倍。例如數字“-13142223336”是個11位數,其中有3個2,並且是負數,也是偶數,則它的犯二程度計算為:3/11*1.5*2*100%,約為81.82%。本題就請你計算一個給定整數到底有多二。
輸入格式:
輸入第一行給出一個不超過50位的整數N。
輸出格式:
在一行中輸出N犯二的程度,保留小數點後兩位。
輸入樣例:-13142223336輸出樣例:
81.82%
#include<stdio.h> #include<stdlib.h> int main() { char |