10進製整數轉化成36進製字串:
#include "stdafx.h"
#include
int main()
for(i = 0; num; i++)
for(i--; i >= 0; i--)
printf("%c", (a[i] < 10) ? (a[i] + '0') : (a[i] - 10 + 'a'));
printf("\n");
return 0;
}--引數描述:@hex10 被轉換10進製數字
--測試方法:select [dbo].[converthex10to36](17122394)
create function [dbo].[converthex10to36]
(@hex10 int)
returns varchar(100)
as--declare @hex10 int set @hex10=17122394 --注釋as(包括as)以上所有行,將**最後的return換成print,並設該行為斷點,按f11開始除錯
begin
declare @strhex36 varchar(100)--返回36進製表示的結果
declare @remainder int--餘數
declare @base36 varchar(1)
set @remainder=0
set @strhex36=''
while @hex10>0
begin
set @remainder=@hex10%36
set @hex10=@hex10/36
set @base36=substring('0123456789abcdefghijklnmopqrstuvwxyz',@remainder+1,1)
set @strhex36=@base36+@strhex36
end--print @strhex36
return @strhex36
end--測試方法:select dbo.converthex36to10('a6zq2')
create function dbo.converthex36to10
(@strhex36 varchar(100))
returns int
asbegin
declare @strhex36len int --被轉換36進製字串的長度
declare @base36to10 int --每位36進製基數對應的10進製資料大小
declare @index int --字串索引
declare @hex10 int --被返回10進製資料
declare @base36 varchar(1)--36進製基數
set @hex10=0
set @strhex36len=len(@strhex36)
set @index=1
while @index<=@strhex36len
begin
set @base36=substring(@strhex36,@index,1)
set @base36to10=charindex(@base36,'0123456789abcdefghijklmnopqrstuvwxyz')-1
set @hex10=@hex10+@base36to10*power(36,@strhex36len-@index)
set @index=@index+1
endreturn @hex10
end
進製轉化進10進製數
option explicit private sub form click dim st as integer,dem as long st inputbox 輸入乙個十六進製制數 dem convert st print st dem end sub private function conve...
8位10進製數變成32進製數
1 輸入乙個最大的數,確定需要的多少個32進製位 int getdigitnum32 unsigned int max return num 2 無符號數轉換成字元 char numtochar unsigned int num,int base,char buf,int max digit els...
10進製數轉換成2進製數
2.十進位制轉換成二進位制 演算法 利用while語句 當所輸入的數不為1時,執行while迴圈 在while迴圈中將輸入的數插入順序棧中 只支援整形資料 include using namespace std const int stacksize 10 class seqstack seqsta...