Laman

25 Januari, 2011

Bab 10 #define


/***contoh define**/
#include "stdio.h"
#include "conio.h"

#include<iostream.h>
#define PI 3.141592
#define L(n) PI*n*n
#define LS(a,t) (a*t)/2
#define VS(r,t) PI*r*r*t
#define dia main()
#define aku getch()
#define mereka cout<<
 dia

{
clrscr() ;
mereka"Luas Silinder Yang Jari-jarinya = 5, Tinggi=10 adalah" << L(5);
mereka"luas st a=3 t=3" << LS (3,2);
mereka"voulm r=5 t=10" << VS(5,10);

   aku ;
}



/***contoh define**/
#include "stdio.h"
#include "stdlib.h"
#define SWAP(a,b)  {int t; t=a; a=b; b=t;}
#define INDEX 8

void bubble_srt(int a[], int n);
int main (void)

{
int i;
int array[INDEX]={12, 9, 4, 99, 120, 1, 3, 10};
printf("sblm diurutkan:\n");
for (i=0; i< INDEX; i++)
printf("%d ",array[i] );
printf("\n");
bubble_srt(array, INDEX ); //mengurutkan array
printf ("\nsetelah diurutkan:\n");
for (i=0;i<INDEX; i++)
printf("%d ", array[i]);
printf ("\n\n");
system("PAUSE"); //menghentikan tmpln
return 0;
}

/***
fungsi bubble_sort       */
void bubble_srt (int a[],int n)
{
int i,j;
for (i=0; i<n; i++)
    {for (j=1;j<(n-i); j++)
      {if(a[j-1]>a[j])
        SWAP (a[j-1],a[j]);
      }
  }
}

23 Januari, 2011

contoh linklist

#include<iostream>
using namespace std;
struct Node
{
int val; Node *next;    
}*q;
int main()
{
Node *p, *t;            int num;
int loopCount = 0;     int maxCount = 5;
cout<<"Enter "<<maxCount<<" numbers for your linked list."<<endl;
while(loopCount!=maxCount)
{
loopCount++;
cin>>num;
cout<<endl;

if(q == NULL)    
{
q = new Node;
q->val = num;
q->next = NULL;
}
else
{
p = q;
while(p->next!=NULL)
p = p->next;

t = new Node; t->val = num; t->next = NULL; //set next node to NULL
p->next = t;
}
}

cout<<"Here is your linked list"<<endl;
cout<<endl;

for(p = q; p != NULL; p = p->next) {
cout<<p->val<<endl;
}

cout<<endl;
cin.get();

return 0;

}
Who says I can't get stoned 
Turn off the lights and the telephone 
Me in my house alone 
Who says I can't get stoned 

Who says I can't be free 
From all of the things that I used to be 
Rewrite my history 
Who says I can't be free 

It's been a long night in New York City 
It's been a long night in Baton Rouge 
I don't remember you looking any better 
But then again I don't remember you 

Who says I can't get stoned 
Call up a girl that I used to know 
Fake love for an hour or so 
Who says I can't get stoned 

Who says I can't take time 


Meet all the girls in the county line 
Wait on fate to send a sign 
Who says I can't take time 

It's been a long night in New York City 
It's been a long night in Austin too 
I don't remember you looking any better 
But then again I don't remember you 

Who says I can't get stoned 
Plan a trip to Japan alone 
Doesn't matter if I even go 
Who says I can't get stoned 

It's been a long night in New York City 
It's been a long time since 22 
I don't remember you looking any better 
But then again I don't remember you

21 Januari, 2011

I could stay awake just to hear you breathing
Watch you smile while you are sleeping
Far away and dreaming
I could spend my life in this sweet surrender
I could stay lost in this moment forever
Well, every moment spent with you
Is a moment I treasure

I don't wanna close my eyes
I don't wanna fall asleep
'Cause I'd miss you, babe
And I don't wanna miss a thing
'Cause even when I dream of you
The sweetest dream will never do
I'd still miss you, babe
And I don't wanna miss a thing

Lying close to you
Feeling your heart beating
And I'm wondering what you're dreaming
Wondering if it's me you're seeing
Then I kiss your eyes and thank God we're together
And I just wanna stay with you
In this moment forever, forever and ever

I don't wanna close my eyes
I don't wanna fall asleep
'Cause I'd miss you, babe
And I don't wanna miss a thing
'Cause even when I dream of you
The sweetest dream will never do
I'd still miss you, babe
And I don't wanna miss a thing

I don't wanna miss one smile
I don't wanna miss one kiss
Well, I just wanna be with you
Right here with you, just like this
I just wanna hold you close
Feel your heart so close to mine
And stay here in this moment
For all the rest of time

Don't wanna close my eyes
Don't wanna fall asleep
'Cause I'd miss you, babe
And I don't wanna miss a thing
'Cause even when I dream of you
The sweetest dream will never do
'Cause I'd still miss you, babe
And I don't wanna miss a thing

I don't wanna close my eyes
I don't wanna fall asleep
'Cause I'd miss you, babe
And I don't wanna miss a thing
'Cause even when I dream of you
The sweetest dream will never do
I'd still miss you, babe
And I don't wanna miss a thing

Don't wanna close my eyes
Don't wanna fall asleep, yeah
I don't wanna miss a thing