POST YOUR C++ PROGRAMS iR ! SiMPLE ->
+2
L'Jyen [♥]
deathrowcore
6 posters
Page 1 of 1
POST YOUR C++ PROGRAMS iR ! SiMPLE ->
POST IR
anything that can help our young IT's to improve their skills.
for example...
fibonacci sequence
sorting algorithm
here's an example
bubble sort code
#include <iostream>
using namespace std;
int compare(int, int);
void sort(int[], const int);
void swap(int *, int *);
int compare(int x, int y)
{
return(x > y);
}
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void sort(int table[], const int n)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n-1; j++)
{
if(compare(table[j], table[j+1]))
swap(&table[j], &table[j+1]);
}
}
}
int quantity;
int* tab;
int main()
{
cout << "Input quantity: ";
cin >> quantity;
tab = new int [quantity];
cout << "Input numbers: \n\n";
for (int i = 0; i < quantity; i++)
{
int x = i;
cout << "#" << ++x << ": ";
cin >> tab[i];
}
cout << "\nBefore sorting: ";
for (int i = 0; i < quantity; i++)
{
cout << tab[i] << " ";
}
cout << "\nAfter sorting: ";
sort(tab, quantity);
for(int i = 0; i < quantity; i++)
{
cout << tab[i] << " ";
}
return 0;
}
anything that can help our young IT's to improve their skills.
for example...
fibonacci sequence
sorting algorithm
here's an example
bubble sort code
#include <iostream>
using namespace std;
int compare(int, int);
void sort(int[], const int);
void swap(int *, int *);
int compare(int x, int y)
{
return(x > y);
}
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void sort(int table[], const int n)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n-1; j++)
{
if(compare(table[j], table[j+1]))
swap(&table[j], &table[j+1]);
}
}
}
int quantity;
int* tab;
int main()
{
cout << "Input quantity: ";
cin >> quantity;
tab = new int [quantity];
cout << "Input numbers: \n\n";
for (int i = 0; i < quantity; i++)
{
int x = i;
cout << "#" << ++x << ": ";
cin >> tab[i];
}
cout << "\nBefore sorting: ";
for (int i = 0; i < quantity; i++)
{
cout << tab[i] << " ";
}
cout << "\nAfter sorting: ";
sort(tab, quantity);
for(int i = 0; i < quantity; i++)
{
cout << tab[i] << " ";
}
return 0;
}
Last edited by deathrowcore on Sat Nov 14, 2009 9:24 am; edited 1 time in total
deathrowcore- Newbie
-
Posts : 17
Age : 31
Joined date : 2009-10-29
Location : pampanga
Cash : 26559
Re: POST YOUR C++ PROGRAMS iR ! SiMPLE ->
the programmed program??
like a program of a survey?
is it like that?
specify please..
like a program of a survey?
is it like that?
specify please..
Re: POST YOUR C++ PROGRAMS iR ! SiMPLE ->
^ oops.. spam yan!
kindly specify ur subject pls.
we don't understand ee..
kindly specify ur subject pls.
we don't understand ee..
XED- Global Moderator
-
Posts : 6137
Age : 113
Joined date : 2009-10-22
Location : sa bag mo :]]
Cash : 31132
Re: POST YOUR C++ PROGRAMS iR ! SiMPLE ->
*
this is an example code for a C++ program...
___
thanks for sharin this..
for a better reading purposes...
u can ease the space by using
[c0de][/c0de]..
it can maximize tha space ur using..
i know codes are long..^^
this is an example code for a C++ program...
___
thanks for sharin this..
for a better reading purposes...
u can ease the space by using
[c0de][/c0de]..
it can maximize tha space ur using..
i know codes are long..^^
jhennyz- DPC Addict
-
Posts : 148
Age : 31
Joined date : 2010-03-04
Location : ~NOWHERETOFiND~
Cash : 26566
Re: POST YOUR C++ PROGRAMS iR ! SiMPLE ->
check the title please...only post c++ codes.. Thank you
Null- DPC Guest
-
Posts : 625
Age : 33
Joined date : 2009-10-29
Location : Regina Parquez's Heart
Cash : 26754
Similar topics
» simple DPC siggy
» my simple profile. XD
» Simple Neon Text Effect
» Before you post a new topic here..
» POST YOUR JAVA CODES EXAMPLE..
» my simple profile. XD
» Simple Neon Text Effect
» Before you post a new topic here..
» POST YOUR JAVA CODES EXAMPLE..
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|