教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 幼儿教育 >

C语言编程实例100题(4)

来源:网络收集 时间:2026-03-22
导读: break; case 'W':printf(wednesday\n);break; default: printf(data error\n); } } } ============================================================== 【程序32】 题目:Press any key to change color, do you w

break;

case 'W':printf("wednesday\n");break;

default: printf("data error\n");

}

}

}

==============================================================

【程序32】

题目:Press any key to change color, do you want to try it. Please hurry up!

1.程序分析:

2.程序源代码:

#i nclude <conio.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 continue\r\n");

getch();/*输入字符看不见*/ }

}

==============================================================

【程序33】

题目:学习gotoxy()与clrscr()函数

1.程序分析:

2.程序源代码:

#i nclude <conio.h>

void main(void)

{

clrscr();/*清屏函数*/ textbackground(2);

gotoxy(1, 5);/*定位函数*/ cprintf("Output at row 5 column 1\n");

textbackground(3);

}

==============================================================

【程序34】

题目:练习函数调用

1. 程序分析:

2.程序源代码:

#i nclude <stdio.h>

void hello_world(void)

{

printf("Hello, world!\n");

}

void three_hellos(void)

{

int counter;

for (counter = 1; counter <= 3; counter++)

hello_world();/*调用此函数*/ }

void main(void)

{

three_hellos();/*调用此函数*/ }

==============================================================

【程序35】

题目:文本颜色设置

1.程序分析:

2.程序源代码:

#i nclude <conio.h>

void main(void)

{

int color;

for (color = 1; color < 16; color++)

{

textcolor(color);/*设置文本颜色*/ cprintf("This is color %d\r\n", color);

}

textcolor(128 + 15);

cprintf("This is blinking\r\n");

}

==============================================================

【程序36】

题目:求100之内的素数

1.程序分析:

2.程序源代码:

#i nclude <stdio.h>

#i nclude "math.h"

#define N 101

main()

{

int i,j,line,a[N];

for(i=2;i<N;i++) a[i]=i;

C语言编程实例100题(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/38178.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)