贝壳电子书 > 基础科学电子书 > 经典c语言程序设计100例 >

第3章

经典c语言程序设计100例-第3章

小说: 经典c语言程序设计100例 字数: 每页4000字

按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!



      if((letter=getch())'a')
       printf(〃saturdayn〃);
      else if ((letter=getch())'u')
          printf(〃sundayn〃);
        else printf(〃data errorn〃);
      break;
case 'F':printf(〃fridayn〃);break;
case 'M':printf(〃mondayn〃);break;
case 'T':printf(〃please input second lettern〃);
      if((letter=getch())'u')
       printf(〃tuesdayn〃);
      else if ((letter=getch())'h')
          printf(〃thursdayn〃);
        else printf(〃data errorn〃);
      break;
case 'W':printf(〃wednesdayn〃);break;
default: printf(〃data errorn〃);
   }
  }


【程序32】
题目:Press any key to change color; do you want to try it。 Please hurry up!
1。程序分析:            
2。程序源代码:
#include 
void main(void)

int color;
for (color = 0; color 《 8; color++)
  { 
  textbackground(color);/*设置文本的背景颜色*/
  cprintf(〃This is color %drn〃; color);
  cprintf(〃Press any key to continuern〃);
  getch();/*输入字符看不见*/
  }


【程序33】
题目:学习gotoxy()与clrscr()函数   
1。程序分析:
2。程序源代码:
#include 
void main(void)

clrscr();/*清屏函数*/
textbackground(2);
gotoxy(1; 5);/*定位函数*/
cprintf(〃Output at row 5 column 1n〃);
textbackground(3);
gotoxy(20; 10);
cprintf(〃Output at row 10 column 20n〃);


【程序34】
题目:练习函数调用
1。 程序分析: 
2。程序源代码:
#include 
void hello_world(void)

printf(〃Hello; world!n〃);

void three_hellos(void)

int counter;
for (counter = 1; counter 

返回目录 上一页 下一页 回到顶部 1 1

你可能喜欢的