求C语言颜色代码大全,谢谢!

Python078

求C语言颜色代码大全,谢谢!,第1张

已经按你的要求重新改写,简化。

本题一个完整的c程序如下,程序在tc2.0和win-tc下运行通过,结果正确。

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

main()

{float pi=3.14159265,r

textbackground(YELLOW)/* 设置背景色为黄色,注意颜色应该大写,可更改 */

textcolor(RED)/* 设置文件颜色为红色,可更改 */

clrscr()/* 清屏,使设置生效 */

printf("enter radius:")

scanf("%f",&r)

if(r<0)

printf("Enter Error!\n")

else

printf("r=%.2f,c=%.2f,area=%.2f\n",r,2*pi*r,pi*r*r)

system("pause")/* 暂停,按任一键继续 */

}

---------------------------------------------------------------------

---------------------------------------------------------------------

以下仅供参考。可以连续输入8次,每次得到的颜色不同,当然可以改变for (color = 0color <8color++)中color<8的数值来控制输出的颜色数。

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<graphics.h>

main()

{float pi=3.14159265,r

int color

for (color = 0color <8color++)

{

textbackground(color)

cprintf("This is color %d\r\n", color)

cprintf("enter radius:")

scanf("%f",&r)

if(r<0)

cprintf("Enter Error!\r\n")

else

cprintf("r=%.2f,c=%.2f,area=%.2f\r\n",r,2*pi*r,pi*r*r)

cprintf("Press any key to continue\r\n")

getch()

}

system("pause")

}

你可以参阅:

http://zhidao.baidu.com/question/86663727.html

http://zhidao.baidu.com/question/79605706.html

http://zhidao.baidu.com/question/79605348.html

(1) scanf("%d%d%d",&red,&green,&blue)//输入三个值

(2) red = red%256

blue =blue%256

green = green%256//将数据转换到0~255之间

(3)rgb = red | (green<<8) | (blue<<16)//通过或运算将数据放到对应位置上

(4)0x%x //以16进制输出数据

1,用样式表(css),在组件里面加上style属性,例如:

<div style="background-color:bluefont-family:宋体">

欢迎你

</div>

2,直接在字体两边加font标记,例如:

<font color=blue >欢迎你</font>

扩展资料

<input name="submit" type="submit" value="changeColor" onClick="changeColor()">

<span id="wenzi">wenzi</span>

<script>

function changeColor(){

document.all['wenzi'].style.color="#ff0000"

}

</script>

参考资料:百度百科 CSS(层叠样式表)