b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c++ strchr函数_strchr函数返回_模拟实现strchr函数(6)

电脑杂谈  发布时间:2017-02-28 08:29:56  来源:网络整理

print_subset(n,b,0);

}

}

#include <iostream>

using namespace std;

int n = 4;

void subset()

{

for(int S = 0; S < (1<<n); S)

{

cout << "S : " << S << " => ";

for(int i = 0; i < n; i)

{

if(S & (1<<i))

{

cout << i << "";

}

}

cout << endl;

}

}

int main()

{

subset();

}

#include <iostream>

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

#include <string.h>

using namespace std;

const int maxn=500005;

int n;

int aa[maxn]; //离散化后的数组

int c[maxn]; //树状数组

struct Node

{

int v;

int order;

}in[maxn];

int lowbit(int x)

{

return x&(-x);

}

void update(int t,int value)

{

int i;

for(i=t;i<=n;i=lowbit(i))

{

c[i]=value;

}

}

int getsum(int x)

{

int i;

int temp=0;

for(i=x;i>=1;i-=lowbit(i))

{

temp=c[i];

}

return temp;

}

bool cmp(Node a ,Node b)

{

return a.v<b.v;

}

int main()

{

int i,j;

while(scanf("%d",&n)==1 && n)

{

//离散化

for(i=1;i<=n;i)

{

scanf("%d",&in[i].v);

in[i].order=i;

}

sort(in1,inn1,cmp);

for(i=1;i<=n;i) aa[in[i].order]=i;

//树状数组求逆序

memset(c,0,sizeof(c));

long long ans=0;

for(i=1;i<=n;i)

{

update(aa[i],1);

ans=i-getsum(aa[i]);

}

cout<<ans<<endl;

}

return 0;

}

math.h 数学函数库,一些数学计算的公式的具体实现是放在math.h里,具体有:

doublesin (double);

doublecos (double);

doubletan (double);

doubleasin (double); //结果介于[-PI/2, PI/2]


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-34960-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...