当前位置:网站首页>1027 colors in Mars (20 points)
1027 colors in Mars (20 points)
2022-06-30 14:55:00 【Xue Dongjing】
1027 Colors in Mars (20 branch )
The question
Give three numbers ( Decimal system ,0-168) Represents red, green and blue , Convert these three numbers into 13 Base number , If there is only one bit of a color, fill it 0 Complete to two .
Ideas
Hexadecimal conversion , Respectively for 13 Quotient and remainder , Finally, judge whether the result is two , Supplement if not 0, If the number in a bit exceeds ten, use ABC Instead of . Be careful 0.
Code
#include<stdio.h>
void function(int N,int b)
{
if(N==0){
printf("00");
}else{
int x[10],count=0,weight=1,sum=0;
int flag=0;
while(N){
x[count++]=N%b;
N/=b;
}
if(count==1){
printf("0");
}
for(int i=count-1;i>=0;i--){
if(x[i]>9){
printf("%c",'A'+x[i]-10);
}else{
printf("%d",x[i]);
}
}
}
}
int main()
{
int R,G,B;
scanf("%d%d%d",&R,&G,&B);
printf("#");
function(R,13);
function(G,13);
function(B,13);
return 0;
}
边栏推荐
- NoViableAltException([email protected][])
- Text matching - [naacl 2021] augsbert
- Finding the root of an integer by dichotomy
- Error $(...) size is not a function
- Lfi-rce without controllable documents
- Location of dichotomy
- Non decreasing column
- 2021-07-15Caused by: org. quartz. ObjectAlreadyExistsException: Unable to store Job : ‘DEFAULT. TASK_ 1‘
- Bucket sorting (C language)
- JS to realize simple lottery function
猜你喜欢

Matlab judge palindrome number (only numbers)

【BUUCTF】 Have Fun

CCF date calculation (Full Score code + skill summary) February 2, 2015

After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs

ThinkPHP show method parameter controllable command execution

@PathVariable

JS to realize simple lottery function

How does hbuilder display in columns?

ctfshow nodejs

Determine the number of digits of an integer in MATLAB (one line of code)
随机推荐
2021-08-05 leetcode notes
Double pointer letter matching
V3_ Chrome extended Chinese translation document V3 directory
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
[extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network
Finding the root of an integer by dichotomy
Quick sort (C language)
val_ Loss decreases first and then increases or does not decrease but only increases
Searching for single element in dichotomy
2021 geek challenge Web
CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3
In situ merging of two arrays with two pointers
[untitled]
Matlab to find prime pairs within 100
Working principle and fault treatment of cutting cylinder in CNC machining center
Experiment 2: stack
NoViableAltException([email protected][])
Three ways and differences of defining functions in JS
@PathVariable
HD mechanical principle · classic dynamic drawing of mechanical design