码迷,mamicode.com
首页 > 其他好文 > 详细

rwkj 1518

时间:2014-08-10 12:39:50      阅读:361      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   strong   for   

 

bubuko.com,布布扣
#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid+1; 
     }
     return 0;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==0 ) printf("No found!\n"); 
        else printf("%d\n",y);
    }
    return 0;
} 
View Code

#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid+1;
     }
     return 0;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==0 ) printf("No found!\n");
        else printf("%d\n",y);
    }
    return 0;
}

 

 

 

 

 

bubuko.com,布布扣
#include<stdio.h>
int a[30],x;
int f(int low,int high)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid; 
     }
     return -1;
}

int main()
{
    int n,i,y;
    while(scanf("%d",&n)!=EOF)
    {   for(i=0;i<=n;i++)
          scanf("%d",&a[i]);
        x=a[n];
        y=f(0,n-1);
        if (  y==-1 ) printf("No found!\n"); 
        else printf("%d\n",y+1);
    }
    return 0;
} 
View Code

 

 

 

#include<stdio.h>
int a[30],x;
int f(int low,int high)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid;
     }
     return -1;
}

int main()
{
    int n,i,y;
    while(scanf("%d",&n)!=EOF)
    {   for(i=0;i<=n;i++)
          scanf("%d",&a[i]);
        x=a[n];
        y=f(0,n-1);
        if (  y==-1 ) printf("No found!\n");
        else printf("%d\n",y+1);
    }
    return 0;
}

 

 

 

bubuko.com,布布扣
#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid; 
     }
     return -1;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==-1 ) printf("No found!\n"); 
        else printf("%d\n",y+1);
    }
    return 0;
} 
View Code

#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid; 
     }
     return -1;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==-1 ) printf("No found!\n");
        else printf("%d\n",y+1);
    }
    return 0;
}

 

 

 

 

 

 

 

 

bubuko.com,布布扣
#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid+1; 
     }
     return -1;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==-1 ) printf("No found!\n"); 
        else printf("%d\n",y);
    }
    return 0;
} 
View Code

#include<stdio.h>
int f(int a[],int low,int high,int x)
{    int mid;
     while (low<=high)
     {
        mid=(low+high)/2;
        if(a[mid]>x) high=mid-1;
            else if(a[mid]<x) low=mid+1;
                else return mid+1;
     }
     return -1;
}

int main()
{
    int a[30],n,i,x,y;

    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<=n;i++)
        scanf("%d",&a[i]);
        x=a[n];
        y=f(a,0,n,x);
        if (  y==-1 ) printf("No found!\n");
        else printf("%d\n",y);
    }
    return 0;
}

 

rwkj 1518,布布扣,bubuko.com

rwkj 1518

标签:style   blog   http   color   os   io   strong   for   

原文地址:http://www.cnblogs.com/2014acm/p/3902507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!