theCEED.com - Research your Interests!!
  • MEMBERSHIP PROFILE
  • bar
  • No member information.
  • login_button
  • sign_up_button
no_image

Fun Coding Contest

About the ceed

재밌는 코딩 대회 페이지입니다 :)

대회 일정 및 소개[클릭하세요]
Recommend : 9 I Total List : 58 I 2017-01-09
favorite
32번 주제 (16진수,8진수 10진수로 바꾸기) 2017.01.22 20:37:26
Nickname : 1. alphablade Recommend : 0 View : 205 btn_recommend.png declaration

Please enter reasons of report.

declaration

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h >
#include<string.h >
#include<math.h >
int main(){
    char str[16];
    int sum =0,number;
    char a[16] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    scanf("%s", &str);
    int count =strlen(str) -1;
    for(int i =0;i < =strlen(str) -1;i + +){
        for(int j =0;j <16;j + +){
            if(a[j] = =str[i]){
                number  = j;
                break;
            }
        }
        sum + =number *(int)(pow(16.0,(double)count));
        count - -;
    }
    printf("%d",sum);
    return 0;
}
 
cs

저는 %x 사용하지 않았습니다

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h >
#include<string.h >
#include<math.h >
int main(){
    char str[16];
    int sum =0,number;
    char a[8] ={'0','1','2','3','4','5','6','7'};
    scanf("%s", &str);
    int count =strlen(str) -1;
    for(int i =0;i < =strlen(str) -1;i + +){
        for(int j =0;j <8;j + +){
            if(a[j] = =str[i]){
                number  = j;
                break;
            }
        }
        sum + =number *(int)(pow(8.0,(double)count));
        count - -;
    }
    printf("%d",sum);
    return 0;
}
 
cs

%o 사용하지 않고 8진수

list
Comments

name

write a comment
TOTAL  0 Comments
* No comments. Please write comments