CCFCSP:202309-2坐标变换(其二)C语言

#include<stdio.h>
#include<math.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	
	double strench[100000]={1},rotate[100000]={0};
	int ni,mi;
	for(ni=0;ni<n;ni++)
	{
		int type;//操作的类型,1拉伸2旋转 
		double operate;//具体拉伸和旋转的数值
		scanf("%d %lf",&type,&operate);
		switch(type)
		{
			case 1:
				strench[ni+1]=strench[ni]*operate;
				rotate[ni+1]=rotate[ni];
				break;
			case 2:
				strench[ni+1]=strench[ni];
				rotate[ni+1]=rotate[ni]+operate;
				break;
			default:break;
		}
	}
	for(mi=0;mi<m;mi++)
	{
		int i,j;
		double x,y;
		scanf("%d %d %lf %lf",&i,&j,&x,&y);
		double k=strench[j]/strench[i-1];//i到j步中一共拉伸了多少
		double degree=rotate[j]-rotate[i-1];//i到j步中一共旋转了多少度
		double x1=k*x;
		double y1=k*y;
		double x2=x1*cos(degree)-y1*sin(degree);
		double y2=x1*sin(degree)+y1*cos(degree);
		printf("%.3lf %.3lf\n",x2,y2); 
	}
	return 0;
}

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值