- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a,b;
- re:
- system("cls");
- cout<<"請輸入一正整數:";
- cin>>a;
- if(a>0 && a%2==0)
- {
- b=a*5;
- cout<<"該數字的二進位制為:"<<b<<endl;
- }else if(a>0 && a%2>0)
- {
- b=(a-a%2)*5+a%2;
- cout<<"該數字的二進位制為:"<<b<<endl;
- }else
- {
- cout<<"!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?"<<endl;
- }
- system("pause");
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |