The author has 3 posts.
Font size: Small - 100% (Default)  Content converter: No conversion
 
Clicks Replies
1296 2
【程序】自己寫的RGB格式的顏色轉換成十六進制表示的顏色的轉換器
巨大八爪鱼
武林盟主 二十一级
Reply
Floor 1 Posted at: 11/10/15 13:31
// ColorRGB.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    unsigned char red, green, blue;
    while (1)
    {
        printf("Please input the three RGB values: \n");
        scanf_s("%d%d%d", &red, &green, &blue);
        printf("The result is: #%02X%02X%02X\n\n", red, green, blue);
    }
    return 0;
}

巨大八爪鱼
武林盟主 二十一级
Reply
Floor 2 Posted at: 11/10/15 13:32
運行效果:
巨大八爪鱼
武林盟主 二十一级
Reply
Floor 3 Posted at: 11/10/15 13:38
上述程序在編譯成Release版本后無法讀取第二個green的顏色值,所以最好把unsigned char改成unsigned int:
// ColorRGB.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    unsigned int red, green, blue;
    while (1)
    {
        printf("Please input the three RGB values: \n");
        scanf_s("%d%d%d", &red, &green, &blue);
        printf("The result is: #%02X%02X%02X\n\n", red, green, blue);
    }
    return 0;
}


Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
(Shortcut key: Ctrl+Enter)
Post Information
Clicks: 1296 Replies: 2
Author: 巨大八爪鱼
Last reply: 巨大八爪鱼
Last reply time: 11/10/15 13:38
Announcements