Met a girl in the parking lot And all I did was say hello Her pepper spray made it rather hard For me to walk her home But I guess that's the way it goes Tell me again was it love at first sight When I walked by and you caught my eye Wouldn't you know love could shine this bright Well smile because you're the deer in the headlights Met a girl with a graceful charm But when beauty met the beast he froze Got the sense I was not her type By black eye and bloody nose But I guess that's the way it goes Tell me again was it love at first sight When I walked by and you caught my eye Wouldn't you know love could shine this bright Well smile because you're the deer in the headlights It's suffocating to say, but the female mystique take my breath away So give me a smile or give me a sneer Cause i'm trying to guess here Tell me again was it love at first sight When I walked by and you caught my eye Wouldn't you know love could shine this bright Well smile because you're the deer in the headlights Tell me again was it love at first sight When I walked by and you caught my eye Wouldn't you know love could shine this bright If life was a game you would never play nice If love was a beam you'd be blind in both eyes Put your sunglasses 'cause you are the deer in the headlights Well smile because you're the deer in the headlights You're the deer in the headlights You're the deer in the headlights
dodious blog. Powered by Blogger.

Tuesday, November 30, 2010

listing program "mencari nilai mak &min (devide n conquer)"

#include<conio.h>
#include<stdio.h>

int jum, mxb, mnb;
int tab[10];

//menginput banyaknya inputan yang akan dibandingkan

void input(){
    int i;
    printf("masukan jumlah :");
    scanf("%d",&jum);
    for(i=1; i<=jum;i++)
    {
        printf("angka ke-%d: ",i);
        scanf("%d", &tab[i]);
    }
}

//mengecek nilai maksimal dari inputan
int cekmx(int tb[10], int a, int b)
{
    int k, max1, max2;

    if(a==b)
    {
      mxb = tb[a];
    }

    else
    {
      if(a==b-1)
      {

        if(tb[a]<tb[b])
           mxb=tb[b];
        else
        mxb=tb[a];
      }

      else
      {
       k=(a+b)/2;
       max1=cekmx(tb, a, k);
       max2=cekmx(tb, k+1, b);
       if(max1 < max2)
        mxb=max2;
       else
        mxb=max1;
      }
    }
    return mxb;
}
//mengecek nilai mininum dari inputan
int cekmn(int tb[10], int a, int b)
{
  int q, mn1, mn2;
  if(a==b)
  {
    mnb=tb[a];
  }
  else
  {
    if(a==b-1)
    {
    if(tb[a] < tb[b])
        mnb=tb[a];
     else
        mnb=tb[b];
    }
    else
    {
    q=(a+b)/2;
    mn1=cekmn(tb, a, q);
    mn2=cekmn(tb, q+1, b);
    if(mn1 < mn2)
    mnb=mn1;
    else
    mnb=mn2;
    }
   }
  return mnb;
}
/*program utama
menampilkan nilai mak dan min */
main()
{
    clrscr();
    input();
    printf("\n");
    printf("max=%d\n",cekmx (tab, 1, jum));
    printf("min=%d\n",cekmn (tab, 1, jum));
    getch();
    return 0;
}

0 comments:

Post a Comment