diff --git a/code.c++/P1/P1.cpp b/code.c++/P1/P1.cpp new file mode 100644 index 0000000..356e70a --- /dev/null +++ b/code.c++/P1/P1.cpp @@ -0,0 +1,19 @@ +// P1.cpp : 定义控制台应用程序的入口点。 +// + +#include "stdafx.h" +#include "iostream" +using namespace std; +int main() +{ + double n; + cin>>n; + double p,i; + for(i=1; i<=n; i++) + { + p=1/n; + cout<>z; + if(z=="positive") + { + px = pPosCan*pCan; + py = pPosNon*pNon; + } + else if(z=="negative") + { + px = (1-pPosCan)*pCan; + py = (1-pPosNon)*pNon; + } + px=px/(px+py); + py=py/(px+py); + cout<<"p(1)="< +using namespace std; + +double compMean(int x[],int n) +{ + double sum = 0; + for(int i=0;i +using namespace std; + +double compMean(int x[],int n) +{ + double sum = 0; + for(int i=0;i +using namespace std; + +double compMean(int x[],int n) +{ + double sum = 0; + for(int i=0;i>name; + string world[5]={"green","red","red","green","green"}; + double wd[5]; + double p1[5]; + double p2[5]; + if(name=="red") + { + for(int i=0;i<5;i++) + { + p1[i] = wd[i]/sum1(world,5,wd); + cout<>name; + string world[5]={"green","red","red","green","green"}; + double wd[5]; + double p1[5]; + double p2[5]; + if(name=="red,red") + { + for(int i=0;i<5;i++) + { + p1[i] = wd[i]/sum1(world,5,wd); + } + for(int i=0;i<5;i++) + { + p2[i] = wd[i]/sum4(world,5,p1,wd); + cout< +#include +using namespace std; + +int main() +{ + int num, shift; + cout<<"数组长度:"; + cin >> num; + cout<<"右移位数:"; + cin>>shift; + vector array(num); + for (int i = 0; i < num; i++) + cin >> array[i];//输入n个数,区间[0,N) + int pos = shift%num; + if (pos == 0); + else { + while (pos--) { + int temp = array[num - 1]; + for (int i = num - 1; i > 0; i--) array[i] = array[i - 1]; + array[0] = temp; + } + } + for (int i = 0; i < array.size(); i++) { + cout << array[i]<<' '; + } + return 0; +} \ No newline at end of file diff --git a/code.c++/P4/P4.v11.suo b/code.c++/P4/P4.v11.suo new file mode 100644 index 0000000..afa2f5c Binary files /dev/null and b/code.c++/P4/P4.v11.suo differ diff --git a/code.c++/P65/P65.cpp b/code.c++/P65/P65.cpp new file mode 100644 index 0000000..a2b13c9 --- /dev/null +++ b/code.c++/P65/P65.cpp @@ -0,0 +1,32 @@ +// P65.cpp : 定义控制台应用程序的入口点。 +// + +#include "stdafx.h" +#include "iostream" +#include +#include "cmath" +using namespace std; + +float log2(int x) +{ + float t = log(x)/log(2); + return t; +} + +void main() +{ + int num; + cout<<"个数:"; + cin >> num; + vector x(num); + for (int i = 0; i < num; i++) + cin >> x[i];//输入n个数,区间[0,N) + float h=0; + for(int i=0;i