#include <windows.h>
char ColorsArray[] = {BACKGROUND_RED,BACKGROUND_GREEN,BACKGROUND_BLUE };
int main ( void )
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
WORD wOldColorAttrs;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(h, &csbiInfo);
wOldColorAttrs = csbiInfo.wAttributes;
SetConsoleTextAttribute ( h, ColorsArray[0] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1]| BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1]| ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1]| ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1]| BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[1]| ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[0] | ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | ColorsArray[2] | BACKGROUND_INTENSITY );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | ColorsArray[2] );
printf ( " " );
SetConsoleTextAttribute ( h, ColorsArray[1] | ColorsArray[0] );
printf ( " " );
SetConsoleTextAttribute ( h, wOldColorAttrs);
system("pause");
return 0;
}
See the attachment.
- change the names of variables if you can.
- You can change color strips easily by just swapping ColorsArray elements.
- you can also use a loop to show all 25 color strips and also this would be a good coding practice.its just and idea solution and work of 30 minutes. i recommend you to use loop like below
int i;
for(i = 0;i<25;i++){
//color strip code here
}
Gudluck :)
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
No comments:
Post a Comment