#include <stdio.h>
#include <math.h>
#include <vector>
 
using namespace std;

int main()
{
    int i;
     
    int x,y,z;
    char *p;
    double w=2;
    int temp;
    char ch;

    vector<int> vec1;

    vector<unsigned int> vec2;
    
    vector<int> vec3;
    
    scanf("%d",&i);

    for(x=0;x<i;x++)
    {
    scanf(
"%d",&temp);   vec1.push_back(temp);
}
for(x=0;x<i;x++) { for(y=1;y<32;y++) { if((pow(w,y)-1)*2>=vec1[x] && (pow(w,y-1)-1)*2<=vec1[x]) break; } vec2.push_back(y); } for(x=0;x<i;x++) { vec3.push_back(vec1[x]-2*(pow(w,y-1)-1)-1); } for(x=0;x<i;x++) {
     //内存的管理问题 p
= (char*)malloc(sizeof(char)*(vec2[x]+1)); memset(p,0,vec2[x]+1); for(y=0;y<vec2[x];y++) { if(vec3[x]&0x1==1) p[y]=7+'0'; else p[y]=4+'0'; vec3[x] = vec3[x]>>1; } for(y=0,z=vec2[x]-1;y<vec2[x]/2;y++,z--) { ch = p[y]; p[y]= p[z]; p[z]=ch; } printf("%s\n",p); } }

 

相关文章:

  • 2021-06-23
  • 2021-12-01
  • 2021-11-01
  • 2022-12-23
  • 2021-09-09
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
相关资源
相似解决方案