标签:div math main bsp include 转化 span 实现 scan
#include <stdio.h> #include <string.h> #include <math.h> int main() { int n,i,j,k; int e; char num[10][100001]; int sum[10]={0}; int mon[100001]; int i1 = 0,j1 = 0; scanf("%d",&n); //存储 for(i = 0;i < n;i ++) { scanf("%s",num[i]); } //应用 for(i = 0;i < n;i ++) { k = strlen(num[i]); //printf("%d",k); for(j = 0;num[i][j] != ‘\0‘;j ++) { //printf("%d\n",k); //printf("%c\n",num[i][j]); if(num[i][j] >= ‘0‘ && num[i][j] <= ‘9‘) { sum[i] += pow(16,k - 1) * (num[i][j] - ‘0‘); //printf("%d\n",sum[i]); k --; } else { if(num[i][j] == ‘A‘) { sum[i] += pow(16,k - 1) * 10; k --; } else if(num[i][j] == ‘B‘) { sum[i] += pow(16,k -1) * 11; k --; } else if(num[i][j] == ‘C‘) { sum[i] += pow(16,k -1) * 12; k --; } else if(num[i][j] == ‘D‘) { sum[i] += pow(16,k -1) * 13; k --; } else if(num[i][j] == ‘E‘) { sum[i] += pow(16,k -1) * 14; k --; } else { sum[i] += pow(16,k -1) * 15; k --; } } } i1 = 0; //printf("%d",sum[i]); while(sum[i]) { e = sum[i] % 8; mon[i1] = e; sum[i] = sum[i] / 8; i1 ++; } for(j1 = i1 - 1;j1 >= 0;j1 --) { printf("%d",mon[j1]); } printf("\n"); } }
标签:div math main bsp include 转化 span 实现 scan
原文地址:https://www.cnblogs.com/xiaobaiyuan/p/12570951.html