目前共有3篇帖子。 内容转换:不转换▼
 
点击 回复
357 2
【程序】自己寫的RGB格式的顏色轉換成十六進制表示的顏色的轉換器
一派护法 十九级
1楼 发表于:2015-11-10 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;
}

一派护法 十九级
2楼 发表于:2015-11-10 13:32
運行效果:
一派护法 十九级
3楼 发表于:2015-11-10 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;
}


回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:357 回复数:2
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2015-11-10 13:38
 
©2010-2024 Arslanbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。