|
10鱼币
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~不好意思,做了次标题党~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #include <stdio.h>
- #include "conio.h"
- #include "windows.h"
- #include <math.h>
- void main(void)
- {
- int color;
- for(color=0;color<8;color++)
- {
- textbackground(color);
- cprintf("This is color %d\r\n",color);
- cprintf("Press any key to contine\r\n");
- getchar();
- }
- getchar();
- }
复制代码 这个是在C语言100题里面的
关于调用一些函数,看来好像是windows 的系统函数,但是运行不了,
---------------------------------------------------------------------------------球球帮助-----------------------------------------------------------------------------------------------------------------------------------------------------
conio.h 中现在没有改变颜色的函数了(至少我的VS报错)
- /********************************************************************************
- *about:C++字体颜色
- *author:沐雨雨
- *site:http://www.cnblogs.com/forestrain/p/8567097.html/
- ********************************************************************************/
- #include<iostream>
- #include<windows.h>
- using namespace std;
- int main()
- {
- HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);//句柄
- cout << "原色" << endl;
- SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);//三色相加,白色
- cout << "白色" << endl;
- //向外输出
- SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY | FOREGROUND_RED);//红色
- cout << "红色" << endl;
- SetConsoleTextAttribute(hout, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);//红色和绿色相加,黄色
- cout << "黄色" << endl;
- SetConsoleTextAttribute(hout, 64 + 15);
- cout << "深红色背景颜色,浅白色字体颜色" << endl;
- SetConsoleTextAttribute(hout, 79);
- cout << "深红色背景颜色,浅白色字体颜色" << endl;
- int color;
- for(color = 0; color < 100; color++)
- {
- SetConsoleTextAttribute(hout, color);
- cout <<"color" << endl;
- }
- return 0;
- }
复制代码
也可以通过system函数实现:
- #include<iostream>
- using namespace std;
- int main() {
- int color = 0;
- system("color fc");//白底红字
- // f代表白色,在前为底色
- // c代表红色
- cout << color;
- }
复制代码
|
最佳答案
查看完整内容
conio.h 中现在没有改变颜色的函数了(至少我的VS报错)
也可以通过system函数实现:
|