当前位置:网站首页>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;
}
边栏推荐
- CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
- day02
- How to program and process such parts?
- 高精度CNC加工中心为什么会出现误差?这4个原因你要注意!
- CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2
- Solve the problem that codeblocks20.03 on win11 cannot run for the first time
- CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
- Double pointer letter matching
- [extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network
- Lfi-rce without controllable documents
猜你喜欢
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
Ctfshow getting started with the web (ThinkPHP topic)
How to use Alibaba Vector Icon
Error $(...) size is not a function
【BUUCTF】 EasySql
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
Svn password forgetting solution
CCF date calculation (Full Score code + skill summary) February 2, 2015
Thinkphp5 log file contains trick
August 24, 2021 deque queue and stack
随机推荐
Lihongyi machine learning 2020 homework summary
Experiment 2: stack
Lost connection to the flow server (0 retries remaining): |Out of retries, exiting! Error reporting solution (flow)
1076 forwards on Weibo (30 points)
Summary of C language interview questions
ES6 notes
Forward declaration of classes
Database connection to company database denied
【BUUCTF】 Have Fun
1066 root of AVL tree (25 points)
catkin_ Make reports an error, transfers the location of the workspace, and uses other people's workspace files to cause compilation errors
LIS error: this configuration section cannot be used in this path
CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
JS array sorting method summary
Matlab construction operation example
How to program and process such parts?
Maximum area of islands searched
Searching for single element in dichotomy
CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3
浅析卧式加工中心上不规则台阶孔存在问题