CCF-CSP真题训练第二题-《202309坐标变换(其二)》-python

1.真题来源

首页 - 计算机软件能力认证考试系统

2.重点

坐标变换方式的统计。拉伸是多个操作相乘,旋转是多个操作相加。

3.运行结果

![在这里插入图片描述](https://img-blog.csdnimg.cn/dire在这里插入图片描述
t/611ac7bb55e34396b1dd00935085a971.png)
PS:还是有运行超时的问题。欢迎广大网友提供建议~

4.Python运行代码

from math import cos, sin
n, m = map(int, input().split())
T = [[i for i in map(float, input().split())]for j in range(n)]
Location = [[i for i in map(int, input().split())]for j in range(m)]

for i in range(m):
    a = Location[i][0]
    b = Location[i][1]
    sum = 1
    xum = 0
    out = []
    for j in range(a-1, b):
        type = T[j][0]
        if type==1 :
            sum *= T[j][1]
        elif type==2 :
            xum += T[j][1]
        else:
            print("数据读取错误!")
    x = Location[i][2]
    y = Location[i][3]
    x = x*sum
    y = y*sum
    x1 = x*cos(xum)-y*sin(xum)
    y1 = x*sin(xum)+y*cos(xum)
    out.append(x1)
    out.append(y1)
    print(out[0], out[1])
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值