第 1 測資點(100%): WA (line:1)
答案不正確
您的答案為: 1110001100110110 ...略 正確答案為: 11100011001
程式碼:
#include<iostream>
using namespace std;
int main()
{
int n, a[32], i, j;
while (cin >> n)
{
i = 0;
while (n > 0)
{
a[i] = n % 2;
n = n / 2;
i++;
}
while (i > 0)
{
cout << a[i - 1];
i--;
}
for (i = 0; i < n; i++)
{
cout << a[i];
}
}
return 0;
}
第 1 測資點(100%): WA (line:1)
答案不正確
您的答案為: 1110001100110110 ...略 正確答案為: 11100011001
程式碼:
#include
using namespace std;
int main()
{
int n, a[32], i, j;
while (cin >> n)
{
i = 0;
while (n > 0)
{
a[i] = n % 2;
n = n / 2;
i++;
}
while (i > 0)
{
cout << a[i - 1];
i--;
}
for (i = 0; i < n; i++)
{
cout << a[i];
}
}
return 0;
}
讓我猜猜....................................................你忘記換行了
第 1 測資點(100%): WA (line:1)
答案不正確
您的答案為: 1110001100110110 ...略 正確答案為: 11100011001
程式碼:
#include
using namespace std;
int main()
{
int n, a[32], i, j;
while (cin >> n)
{
i = 0;
while (n > 0)
{
a[i] = n % 2;
n = n / 2;
i++;
}
while (i > 0)
{
cout << a[i - 1];
i--;
}
/* 這段可省略八
for (i = 0; i < n; i++)
{
cout << a[i];
}*/
cout<<endl; //好像忘了換行喔
}
return 0;
}