python程序的输入输出(acm的几个小程序)
1, ?A+B Problem :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1000
#!/usr/bin/env python # coding=utf-8 a=[] for x in raw_input().split(): a.append(int(x)) print sum(a)?
2,?A+B for Input-Output Practice (I) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1010
while True: a=[] line = raw_input() if line: for x in line.split(): a.append(int(x)) print sum(a) else: break?
3,?A+B for Input-Output Practice (II) ?: ?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1011
#!/usr/bin/env python #coding:utf8 t = int(raw_input())while t>0:a=[]for x in raw_input().split():a.append(int(x))print sum(a)t=t-14,?A+B for Input-Output Practice (III) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1012
#!/usr/bin/env python #coding:utf8while True:line = raw_input()a=[]for x in line.split():a.append(int(x))if a[0]==0 and a[1]==0:breakprint sum(a)5,?A+B for Input-Output Practice (IV) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1013
#!/usr/bin/env python #coding:utf8while True:num=[]line = raw_input()for x in line.split():num.append(int(x))if num[0]==0:breaka=num[0]print sum(num)-a?
6,?A+B for Input-Output Practice (V) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1014
#!/usr/bin/env python #coding:utf8 t = int(raw_input())while t>0:if t==0:breakline = raw_input()num=[]for x in line.split():num.append(int(x))print sum(num)-num[0]t = t-1?
7,?A+B for Input-Output Practice (VI) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1015
#!/usr/bin/env python #coding:utf8while True:line = raw_input()num=[]for x in line.split():num.append(int(x))print sum(num)-num[0]?
8,?A+B for Input-Output Practice (VII) :?http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1016
被打敗了,被'\r'打敗了,,輸出一個空行,,不解釋
#!/usr/bin/env python #coding:utf8while True:a=[]line = raw_input()for x in line.split():a.append(int(x))print sum(a)print '\r' #輸出一個空行附 : python轉義字符:
在需要在字符中使用特殊字符時,python用反斜杠(\)轉義字符。如下表:
原始字符串有時我們并不想讓轉義字符生效,我們只想顯示字符串原來的意思,這就要用r和R來定義原始字符串。 ? ? ?如: ? ? ? ??print?r'\t\r' ? ? ? ? ?實際輸出為“\t\r”。?
| \(在行尾時) | 續行符 |
| \\ | 反斜杠符號 |
| \' | 單引號 |
| \" | 雙引號 |
| \a | 響鈴 |
| \b | 退格(Backspace) |
| \e | 轉義 |
| \000 | 空 |
| \n | 換行 |
| \v | 縱向制表符 |
| \t | 橫向制表符 |
| \r | 回車 |
| \f | 換頁 |
| \oyy | 八進制數yy代表的字符,例如:\o12代表換行 |
| \xyy | 十進制數yy代表的字符,例如:\x0a代表換行 |
| \other | 其它的字符以普通格式輸出 |
?
ref:?http://www.cnblogs.com/jackge/archive/2013/06/02/3114205.html
轉載于:https://www.cnblogs.com/pinganzi/p/6647168.html
總結
以上是生活随笔為你收集整理的python程序的输入输出(acm的几个小程序)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android应用程序进程启动过程
- 下一篇: 如何在github上fork一个项目来贡