|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在这段代码里,x在代入后无变化,但y在带入后就不一样了,有的符号都变了,下面是我的一些测试代码
- #include<iostream>
- #include<math.h>
- using namespace std;
- void changeXY(int i,int j,const int sw[],const double v[],double &x,double &y){
- double v_k=1;
- double v_c=0;
- for(int k=i-1;k<=j-1;k++){
- if(sw[k]==1){
- v_k*=v[k];
- }else{
- v_c+=v[k];
- }
- }
- cout<<"------------"<<endl;
- printf("%f %f\n",(x * cos(v_c) - y * sin(v_c)) * v_k,(x * sin(v_c) + y * cos(v_c)) * v_k);
- cout << fixed << (x * cos(v_c) - y * sin(v_c)) * v_k << " "
- << (x * sin(v_c) + y * cos(v_c)) * v_k << endl;
- x=(x * cos(v_c) - y * sin(v_c)) * v_k;
- y=(x * sin(v_c) + y * cos(v_c)) * v_k;
- cout<<x<<" "<<y<<endl;
- cout<<"------------"<<endl;
- }
- int main(){
- int n,m;
- cin>>n>>m;
- int sw[n];
- double v[n];
- for(int k=0;k<n;k++){
- cin>>sw[k]>>v[k];
- }
- int i,j;
- double x[m],y[m];
- for(int k=0;k<m;k++){
- cin>>i>>j>>x[k]>>y[k];
- changeXY(i,j,sw,v,x[k],y[k]);
- }
- cout<<"***************"<<endl;
- for(int k=0;k<m;k++){
- printf("%f %f\n",x[k],y[k]);
- }
- return 0;
- }
复制代码
下面还有题目给的测试数据:
输入:
10 5
2 0.59
2 4.956
1 0.997
1 1.364
1 1.242
1 0.82
2 2.824
1 0.716
2 0.178
2 4.094
1 6 -953188 -946637
1 9 969538 848081
4 7 -114758 522223
1 9 -535079 601597
8 8 159430 -511187
输出:
-1858706.758 -83259.993
-1261428.46 201113.678
-75099.123 -738950.159
-119179.897 -789457.532
114151.88 -366009.892 |
|