题目:学习gotoxy()与clrscr()函数
1.程序分析:
2.程序源代码:
#include "conio.h"
#include "stdio.h"
void main(void)
{
clrscr();/*清屏函数*/
textbackground(2);
gotoxy(1, 5);/*定位函数*/
cprintf("Output at row 5 column 1\n");
textbackground(3);
gotoxy(20, 10);
cprintf("Output at row 10 column 20\n");
getch();
}
1.程序分析:
2.程序源代码:
#include "conio.h"
#include "stdio.h"
void main(void)
{
clrscr();/*清屏函数*/
textbackground(2);
gotoxy(1, 5);/*定位函数*/
cprintf("Output at row 5 column 1\n");
textbackground(3);
gotoxy(20, 10);
cprintf("Output at row 10 column 20\n");
getch();
}
题目:练习函数调用
1. 程序分析:
2.程序源代码:
#include "stdio.h"
#include "conio.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();/*调用此函数*/
getch();
}
题目:文本颜色设置
1.程序分析:
2.程序源代码:
1. 程序分析:
2.程序源代码:
#include "stdio.h"
#include "conio.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();/*调用此函数*/
getch();
}
题目:文本颜色设置
1.程序分析:
2.程序源代码:
#include "stdio.h"
#include "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");
getch();
}
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");
getch();
}