本文目录一览:
python中如何实现一行输入多个值
此题目就是先求出四个数中的最大数、最小数,之后求平均啊!main(){int a,b,c,d,max,min;scanf("%d%d%d%d",a,b,c,d);max=min=a;if(ba)max=b;elsemin=b;if(cmax)max=c;if(minc)min=c;if(dmax)max=d;if(mind)min=d;printf("max=%d,min=%d,avg=%fn",max,min,(max+min)/2.0);}
python中如何在一行输入n个数字
直接用input输入就可以了啊,输入以后当作字符串处理,按照空格或者逗号等分隔符划分成字符串数组,最后对得到的字符串数组做强制类型转换就可以了。
python怎么在一行中输入n个数
以下代码调试通过:
l = [] for i in range(5): n = input("please enter the number:") l.append(n) print('l:', l)
运行效果:
please enter the number:12please enter the number:34please enter the number:56please enter the number:35please enter the number:22l: ['12', '34', '56', '35', '22'] Process finished with exit code 0
python一行写多条语句
一行多语句
一行输入多个语句,用分号隔开
print('hello');print('world')
如何用python实现一行两个输入
输入的时候用分割符分开,在后面的代码中通过split()切分出前后2个值就好
ostr = raw_input(u'请输入信息,用/分隔:')
first = ostr.split('/')[0]
second = ostr.split('/')[1]
print first
print second