⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.cpp

📁 数据结构中如何将十进制转换为六禁止
💻 CPP
字号:
typedef int SElemType;
typedef int QElemType;

#include "commdef.h"
#include "sqstack.h"
#include "SqQueue传引用.h"
#include"math.h"

void zhengshu(int N)
{int a;
SqStack S;
SElemType e;
 InitStack(S); 
 if(N==0)  Push(S,0);
 while(N!=0)
 { a=N%16;
  
   Push(S,a);
  
      N=N/16;
  }
 while(!StackEmpty(S))
 {
  Pop(S,e);
  printf("%X",e);
  
 }
}

void xiaoshu(float m)
{int a;int bit=0;
SqQueue Q;
QElemType e;
InitQueue(Q);
     while(fabs(m)>1e-6&&bit<5)
       {m=m*16;
         a=(int)m;
       
         EnQueue(Q,a); 
         m=m-a;
		 bit++;
        }
   while(Q.rear!=Q.front)
   {
    DeQueue(Q,e);
      printf("%X",e);
    }
}
void main()
{float c,m;int N;
scanf("%f",&c);
N=(int) c;
 m=c-N;
zhengshu(N);
 if (m!=0) printf(".");
 xiaoshu(m);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -