日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

比较经典的位字段例题(颜色三原色)

發布時間:2023/12/20 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 比较经典的位字段例题(颜色三原色) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include "stdafx.h" /*是否透明和是否可見*/ #define YES 1 #define NO 0 /*邊框線的樣式*/ #define SOLID 0 #define DOTTED 1 #define DASHED 2 /*三原色*/ #define BLUE 4 #define GREEN 2 #define RED 1 /*混合顏色*/ #define BLACK 0 #define YELLOW (RED|GREEN) #define MAGENTA (RED|BLUE) #define CYAN (GREEN|BLUE) #define WHITE (RED|GREEN|BLUE)const char *colors[8] = { "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" };struct box_props{unsigned int opaque : 1;unsigned int fill_color : 3;unsigned int : 4;unsigned int show_border : 1;unsigned int border_color : 3;unsigned int border_style : 2;unsigned int : 2; }; void show_settings(const struct box_props *pb);int _tmain(int argc, _TCHAR* argv[]) {struct box_props box = { YES, YELLOW, YES, GREEN, DASHED };printf("Original box settings:\n");show_settings(&box);box.opaque = NO;box.fill_color = WHITE;box.border_style = SOLID;printf("\n Modified box settings:\n");show_settings(&box);return 0; } void show_settings(const struct box_props *pb) {printf("Box is %s.\n", pb->opaque == YES ? "opaque" : "transparent");printf("The fill color is %s.\n", colors[pb->fill_color]);printf("Border %s.\n", pb->show_border == YES ? "show":"not shown");printf("The border color is %s.\n", colors[pb->border_color]);printf("The border style is ");switch (pb->border_style){case SOLID:printf("solid.\n"); break;case DOTTED:printf("dotted.\n"); break;case DASHED:printf("dashed.\n");break;default:printf("unkown type\n");} } 下面是輸出:Original box settings :
Box is opaque .
The fill color is yellow .
Border show .
The border color is green .
The border style is dashed.
Modified box settings :
Box is transparent .
The fill color is white .
Border show .
The border color is magenta .
The border style is solid.

總結

以上是生活随笔為你收集整理的比较经典的位字段例题(颜色三原色)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。