免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1580 | 回复: 0
打印 上一主题 下一主题

C语言经典100例(Python版本)031-035 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-16 13:14 |只看该作者 |倒序浏览

               
               
                '''
程序31】
题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续
   判断第二个字母。
1.程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母。
2.程序源代码:
'''
from sys import stdin
letter = stdin.read(1)
stdin.flush()
while letter  != 'Y':
    if letter == 'S':
        print 'please input second letter'
        letter = stdin.read(1)
        stdin.flush()
        if letter == 'a':
            print 'Saturday'
        elif letter  == 'u':
            print 'Sunday'
        else:
            print 'data error'
            break
    elif letter == 'F':
        print 'Friday'
        break
    elif letter == 'M':
        print 'Monday'
        #break
    elif letter == 'T':
        print 'please input second letter'
        letter = stdin.read(1)
        stdin.flush()
        if letter  == 'u':
            print 'Tuesday'
        elif letter  == 'h':
            print 'Thursday'
        else:
            print 'data error'
            break
    elif letter == 'W':
        print 'Wednesday'
    else:
        print 'data error'
    letter = stdin.read(1)
    stdin.flush()
        
'''
【程序32】
题目:Press any key to change color, do you want to try it. Please hurry up!
1.程序分析:            
2.程序源代码:
不知道写呢 :(,先空着吧
'''
'''
【程序33】
题目:学习gotoxy()与clrscr()函数   
1.程序分析:
2.程序源代码:
不知道如何写 :( 先空着吧
'''
'''
【程序34】
题目:练习函数调用
1. 程序分析:
2.程序源代码:
'''
def hello_world():
    print 'hello world'
def three_hellos():
    for i in range(3):
        hello_world()
if __name__ == '__main__':
    three_hellos()
'''
【程序35】
题目:文本颜色设置
1.程序分析:
2.程序源代码:
#include
void main(void)
{
int color;
for (color = 1; color ''


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/19742/showart_382968.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP