求指导!为啥70分...

笨办法写的,不知道哪儿错了

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    int a[32];
    int i=0;
    for(int j=0;j<32;j++)a[j]=0;
    while(n!=0){  
        a[i]=n%2;
        i++;
        n=n/2;
    }
    int b[32];
    for(int j=0;j<=15;j++)b[j+16]=a[j];
    for(int j=0;j<=15;j++)b[j]=a[j+16];
    long long result=0;
    int temp=1;
    for(int j=0;j<32;j++){
       result=result+temp*b[j]; 
       temp=temp*2;
    }
    cout<<result;
    return 0;
}

2 条评论

  • @ 2016-12-28 16:14:45

    对,,我用c这样写的,也是70🌚🌚🌚

    • @ 2016-12-28 16:15:21

      用移位就好了,,为啥。。。

  • @ 2014-07-31 11:55:19

    #include <iostream>

    using namespace std;

    int main()
    {
    unsigned long a = 0;

    cin >> a;
    cout << ((a >> 16) + (a << 16));
    return 0;
    }
    不解释

  • 1

信息

ID
1201
难度
3
分类
模拟 点击显示
标签
(无)
递交数
3699
已通过
1824
通过率
49%
被复制
13
上传者