35、36、37
2017-06-09 15:24
218 查看
题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
1.程序分析:同29例
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main( )
{
long ge,shi,qian,wan,x;
scanf("%ld",&x);
wan=x/10000;
qian=x%10000/1000;
shi=x%100/10;
ge=x%10;
if(ge==wan&&shi==qian)/*个位等于万位并且十位等于千位*/
printf("this number is a huiwen\n");
else
printf("this number is not a huiwen\n");
getch();
}
题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续
判断第二个字母。
1.程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母。
2.程序源代码:
#include "stdio.h"
#include "conio.h"
void main()
{
char letter;
printf("please input the first letter of someday\n");
while((letter=getch())!='Y')/*当所按字母为Y时才结束*/
{
switch (letter)
{
case 'S':printf("please input second letter\n");
if((letter=getch())=='a')
printf("saturday\n");
else if ((letter=getch())=='u')
printf("sunday\n");
else printf("data error\n");
break;
case 'F':printf("friday\n");break;
case 'M':printf("monday\n");break;
case 'T':printf("please input second letter\n");
if((letter=getch())=='u')
printf("tuesday\n");
else if ((letter=getch())=='h')
printf("thursday\n");
else printf("data error\n");
break;
case 'W':printf("wednesday\n");break;
default: printf("data error\n");
}
}
getch();
}
题目:Press any key to change color, do you want to try it. Please hurry up!
1.程序分析:
2.程序源代码:
#include "conio.h"
#include "stdio.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();/*输入字符看不见*/
}
}
1.程序分析:同29例
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main( )
{
long ge,shi,qian,wan,x;
scanf("%ld",&x);
wan=x/10000;
qian=x%10000/1000;
shi=x%100/10;
ge=x%10;
if(ge==wan&&shi==qian)/*个位等于万位并且十位等于千位*/
printf("this number is a huiwen\n");
else
printf("this number is not a huiwen\n");
getch();
}
题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续
判断第二个字母。
1.程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母。
2.程序源代码:
#include "stdio.h"
#include "conio.h"
void main()
{
char letter;
printf("please input the first letter of someday\n");
while((letter=getch())!='Y')/*当所按字母为Y时才结束*/
{
switch (letter)
{
case 'S':printf("please input second letter\n");
if((letter=getch())=='a')
printf("saturday\n");
else if ((letter=getch())=='u')
printf("sunday\n");
else printf("data error\n");
break;
case 'F':printf("friday\n");break;
case 'M':printf("monday\n");break;
case 'T':printf("please input second letter\n");
if((letter=getch())=='u')
printf("tuesday\n");
else if ((letter=getch())=='h')
printf("thursday\n");
else printf("data error\n");
break;
case 'W':printf("wednesday\n");break;
default: printf("data error\n");
}
}
getch();
}
题目:Press any key to change color, do you want to try it. Please hurry up!
1.程序分析:
2.程序源代码:
#include "conio.h"
#include "stdio.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();/*输入字符看不见*/
}
}
相关文章推荐
- EC读书笔记系列之16:条款35、36、37、38、39、40
- Effective C++ 35,36,37
- 分别求1+2+3+...+10,20+21+22+...+30与35+36+37+...+45的和
- (35)数组声明方式 (36)数组类型 (37)数组键规则
- 传智播客Hibernate视频教程学习笔记35 36 37
- 看大神文章小结——微软等面试 35,36,37,38
- text1.txt begin10 11 12 20 21 22 30 31 32 end text2.txt begin 15 16 17 25 26 27 35 36 37 得到text3.txt
- Effective C++ 35,36,37
- Lesson 35-36 What did you forget?
- effective C++笔记之条款36、37: 区分接口继承和实现继承、绝不要重新定义继承而来的非虚函数
- [编写高质量代码:改善java程序的151个建议]建议36,37:构造代码块
- Python27 34 35 36安装scipy
- 解决adb的adb server version (32) doesn't match this client (36)或(35)
- leetcode@ [36/37] Valid Sudoku / Sudoku Solver
- 第六章 继承和面向对象设计(35-36)
- NYOJ36与NYOJ37——最长公共子序列
- linux命令学习(35 36)-shutdown reboot
- 剑指offer35/36
- (翻译)Entity Framework技巧系列之九 - Tip 35 - 36
- 继承深入理解-----effective C++条款36、37、38