輸入一個八進制數字字符串?
intmain(){charstr[1024]={0};inti;intresult=0;gets(str);for(i=0;i<strlen(str);i++){if(str[i]>'7'||str[i]<'0'){printf("invalidcharfound\n")
;return-1;}result*=8;result+=str[i]-'0';
}printf("resultis%d\n",result);}
輸入一個八進制數字字符串?
intmain(){charstr[1024]={0};inti;intresult=0;gets(str);for(i=0;i<strlen(str);i++){if(str[i]>'7'||str[i]<'0'){printf("invalidcharfound\n")
;return-1;}result*=8;result+=str[i]-'0';
}printf("resultis%d\n",result);}