Cod sursa(job #212675)

Utilizator bogdanhm999Casu-Pop Bogdan bogdanhm999 Data 6 octombrie 2008 12:51:57
Problema Cautare binara Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include <stdio.h>
long a[100005],p1[100005],p2[100005];
long n,x,i,q;

int main(){
    freopen("cautbin","r",stdin);
    freopen("cautbin.out","w",stdout);
    scanf("%ld\n",&n);
    q=0;a[0]=-1;
    for (i=0;i<n;++i){
        scanf("%ld",x);
        //while (ch[j]!=' '){
        //      x*=10;x+=ch[j]-'0';}
        if (x!=a[q]){a[++q]=x;p1[q]=p2[q]=i+1;}
        else p2[q]++;
    }
return 0;
}