2020.1.3计导全面复习

//用宏定义替换文本 
#include<iostream>
#include<cstdio>
#define p(m,n) printf("Hi,"#m"!\n""...And "#n"~\n")
int main(){
    p(John,Amy);
}
//条件编译
#include<iostream>
#include<cstdio>
#ifdef WIN32
#define PLL "%I64d"
#else
#define PLL "%lld"
#endif
int main(){
    long long x;
    scanf("%lld",&x);
    printf(PLL"\n",x);
}
//用带参宏计算圆的面积和周长
#include<iostream>
#include<cstdio>
#define PI 3.1415926
#define C(r) (2*PI*(r))
#define S(r) (PI*(r)*(r))
int main(){
    double x=1.2;
    printf("%lf\n%lf\n",C(x),S(x));
    return 0;
}
//线性同余产生随机数
#include<iostream>
#include<cstdio>
#include<ctime>
#define maxn 100010
const int a=975323;
const int b=2333333;
const int mod=152487967;
using namespace std;
int X[maxn];
int main(){
    X[0]=time(0);
    for(int i=1;i<=10;i++){
        X[i]=(1LL*a*X[i-1]+b)%mod;
    }
    for(int i=1;i<=10;i++)
        printf("%d ",X[i]);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/thmyl/p/12146270.html
今日推荐