2580 - 概率论与数理统计第4章 第2题
设X、Y是随机变量,且有E(X)=3,E(Y)=2,D(X)=4, D(Y)=9,令Z=4X-Y+12, 分别在下列情况下求E(Z)和D(Z)
(1)X和Y相互独立;
(2)X和Y不相关;
(3)X和Y的相关系数为0.25.
Input
根据输入题号,输出对应结果,用空格隔开。
0
Output
0 1
Examples
Input
0
Output
0 1
Solution C
#include "stdio.h" int main() { int a; int b1,b2,b3,b; while(scanf("%d",&a) != EOF) { if (a==1) { b1=22; b2=73; printf("%d %d\n",b1,b2); ; } else if (a==2) { b1=22; b2=73; printf("%d %d\n",b1,b2); } else if (a==3) { b1=22; // b2=79; b2=71; printf("%d %d\n",b1,b2); } else if (a==0) { printf("0 1\n"); } } return 0; }
Solution C++
#include<iostream> using namespace std; int main() { int a; while(scanf("%d",&a)!=EOF) { if(a==1) cout<<"22"<<" "<<"73"<<endl; else if(a==2) cout<<"22"<<" "<<"73"<<endl; else if(a==3) cout<<"22"<<" "<<"61"<<endl; else cout<<"0"<<" "<<"1"<<endl; } return 0; }