作者共發了3篇帖子。
字體大小:較小 - 100% (默認)  內容轉換:不轉換
 
點擊 回復
1294 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)
本帖信息
點擊數:1294 回複數:2
作者:巨大八爪鱼
最後回覆:巨大八爪鱼
最後回復時間:2015-11-10 13:38
公告板