39
十进制转十六进制的两种方法 莫名其妙指针-百折难回的博客
source link: http://blog.51cto.com/13176924/2095861
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
百折难回的博客 > 正文
十进制转十六进制的两种方法 莫名其妙指针
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
printf("%X\n",n);
return 0;
}
莫名其妙的指针方法
#include<stdio.h>
main()
{
int a[10];
int p;
p=a;
for(int i=0;i<10;i++)
{
scanf("%d",a+i);
}
for(int i=0;i<10;i++)
{
printf("%p ",(p+i));
}
return 0;
}
附加十进制转十六进制
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
char strHex[8];
int i = 0, len = 0, temp = 0;
__int64 nDec = 0;
gets(strHex); len = strlen(strHex); for (i = 0; strHex[i] != '\0'; ++i) { switch(strHex[i]) { case 'A': temp = 10; break; case 'B': temp = 11; break; case 'C': temp = 12; break; case 'D': temp = 13; break; case 'E': temp = 14; break; case 'F': temp = 15; break; default: temp = strHex[i]-'0'; break; } nDec += (temp*pow(16,len-1-i)); } printf("%I64d",nDec); return 0;
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK