欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

AcWing中Python题目

时间:2023-05-18

https://www.acwing.com/problem/content/610/
AcWing 608、差

a=int(input())b=int(input())c=int(input())d=int(input())#print("DIFERENCA = "+str(a*b-c*d))print("DIFERENCA = %d"%(a*b-c*d))

https://www.acwing.com/problem/content/667/
665、倍数

a,b=map(int,input().split(' '))if a%b==0 or b%a==0: print("Sao Multiplos")else: print("Nao sao Multiplos")

https://www.acwing.com/activity/content/code/content/1954611/
670、动物

a=input()b=input()c=input()if a=='vertebrado': if b=='ave': if c=='carnivoro': print('aguia') else: print('pomba') elif b=='mamifero': if c=='onivoro': print('homem') else: print('vaca')else: if b=='inseto': if c=='hematofago': print('pulga') else: print('lagarta') else: if c=='hematofago': print('sanguessuga') else: print('minhoca')

AcWing 660、零食
https://www.acwing.com/problem/content/662/

a,b=map(int,input().split(' '))price=0if a==1: price=4elif a==2: price=4.5elif a==3: price=5elif a==4: price=2else: price=1.5print("Total: R$ %.2lf"%(price*b))

字符串长度
https://www.acwing.com/problem/content/762/

s=input()print(len(s))

721.递增序列
https://www.acwing.com/problem/content/723/

while True: x=int(input()) if x==0: break for i in range(1,x+1): print(str(i)+' ',end='') print()

726.质数
https://www.acwing.com/problem/content/728/

import mathn=int(input())for i in range(n): x=int(input()) flag=1 if x<2: flag=0 for j in range(2,int(math.sqrt(x))+1): if x%j==0: flag=0 break if flag==1: print("%d is prime"%(x)) else: print("%d is not prime"%(x))

745.数组的右上半部分
https://www.acwing.com/problem/content/747/

op=input()N=12f=[[0 for j in range(N)]for i in range(N)]for i in range(N): f[i]=list(map(float,input().split(' ')))sum=0for i in range(N): for j in range(i+1,N): sum+=f[i][j]if op=='S': print("%.1lf"%(sum))else: print("%.1lf"%(sum/((0+11)*12/2)))

756.蛇形矩阵
https://www.acwing.com/problem/content/758/

n,m=map(int,input().split(' '))f=[[0 for j in range(m)] for i in range(n)]dx=[0,1,0,-1]dy=[1,0,-1,0]x,y=0,0cnt=1f[x][y]=cntd=0for i in range(2,n*m+1): while not(x+dx[d]=0 and y+dy[d]=0 and f[x+dx[d]][y+dy[d]]==0): d=(d+1)%4 x=x+dx[d] y=y+dy[d] f[x][y]=ifor i in range(0,n): for j in range(0,m): print(f[i][j],end=' ') print()

823.排列
https://www.acwing.com/problem/content/825/

n,m=map(int,input().split(' '))f=[[0 for j in range(m)] for i in range(n)]dx=[0,1,0,-1]dy=[1,0,-1,0]x,y=0,0cnt=1f[x][y]=cntd=0for i in range(2,n*m+1): while not(x+dx[d]=0 and y+dy[d]=0 and f[x+dx[d]][y+dy[d]]==0): d=(d+1)%4 x=x+dx[d] y=y+dy[d] f[x][y]=ifor i in range(0,n): for j in range(0,m): print(f[i][j],end=' ') print()

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。