C++
#include
#include
using
namespace std;
int
main(int argc, char *argv[])
{
char
tryAgain;
int
arrayType;
do{
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "Choose TYPE - [1] Single Array, [2] Multi-dimentional Array
\n";
cout
<< "\nEnter: ";
cin
>> arrayType;
switch
(arrayType)
{
case
1:
int
arrangeTypeSingle;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "************ SINGLE ARRAY ************* \n";
cout
<< "Choose ARRANGE TYPE - [1] Ascending, [2] Descending \n";
cout
<< "\nEnter: ";
cin
>> arrangeTypeSingle;
switch
(arrangeTypeSingle)
{
case
1:
int
aw[1],jre,rge,air,awTemp;
int
*pair;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "************ SINGLE ARRAY (Ascending)************ \n";
cout
<< "\nNumber of Integers: ";
cin
>> air;
pair
= &air;
air
= *pair;
aw[1]
= aw[air];
cout
<< "\n\nEnter Integers: ";
for(jre=0;jre
cin
>> aw[jre];
for(jre=0;jre
{
for(rge=jre+1;rge
{
if(aw[jre]>aw[rge])
{
awTemp
= aw[jre];
aw[jre]
= aw[rge];
aw[rge]
= awTemp;
}
}
}
cout
<< "\n";
for(jre=0;jre
{
cout
<< aw[jre] << " ";
}
cout
<< "\n";
break;
case
2:
int
ss[1],sss,sad,sun,ssTemp;
int
*psun;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "*********** SINGLE ARRAY (Descending)************** \n";
cout
<< "\nNumber of Integers: ";
cin
>> sun;
psun
= &sun;
sun
= *psun;
ss[1]
= ss[sun];
cout
<< "\n\nEnter Integers: ";
for(sss=0;sss
cin
>> ss[sss];
for(sss=0;sss
{
for(sad=sss+1;sad
{
if(ss[sss]
{
ssTemp
= ss[sss];
ss[sss]
= ss[sad];
ss[sad]
= ssTemp;
}
}
}
cout
<< "\n";
for(sss=0;sss
{
cout
<< ss[sss] << " ";
}
cout
<< "\n";
break;
default:
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "Error: Please try again enter 1 or 2 only! \n";
break;
}
break;
case
2:
int
arrangeTypeMulti;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "************** MULTI-DIMENTIONAL ARRAY *********** \n";
cout
<< "Choose ARRANGE TYPE - [1] Ascending, [2] Decending \n";
cout
<< "\nEnter: ";
cin
>> arrangeTypeMulti;
switch(arrangeTypeMulti)
{
case
1:
int
fs[1][1],fss,ftt,ftbx,exg,fsTemps;
int
*pftbx;
int
nam;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "***************** MULTI-DIMENTIONAL ARRAY
(Ascending)************* \n";
cout
<< "\nNumber of Integers: ";
cin
>> ftbx;
pftbx
= &ftbx;
ftbx
= *pftbx;
nam
= ftbx*ftbx;
fs[1][1]
= fs[ftbx][ftbx];
cout
<< "\n\nEnter "<< nam <<" Integers: ";
for(fss=0;fss
for(ftt=0;fss
cin
>> fs[fss][ftt];
for(fss=0;fss
{
for(ftt=0;ftt
for(exg=0;exg
{
if(fs[fss][ftt]>fs[fss][exg])
{
fsTemps
= fs[fss][ftt];
fs[fss][ftt]
= fs[fss][exg];
fs[fss][exg]
= fsTemps;
}
}
}
for(fss=0;fss
{
for(ftt=0;ftt
{
cout
<< fs[fss][ftt] << " ";
cout
<< "\n";
}
}
break;
case
2:
int
dc[1][1],dcm,ddd,dmim,eee,dcTemps;
int
*pdmim;
int
mnm;
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "************** MULTI-DIMENTIONAL ARRAY
(Descending)************** \n";
cout
<< "\nNumber of Integers: ";
cin
>> dmim;
pdmim
= &dmim;
dmim
= *pdmim;
mnm
= dmim*dmim;
dc[1][1]
= dc[dmim][dmim];
cout
<< "\n\nEnter "<< mnm <<" Integers: ";
for(dcm=0;dcm
for(ddd=0;ddd
cin
>> dc[dcm][ddd];
for(dcm=0;dcm
{
for(ddd=0;ddd
for(eee=0;eee
{
if(dc[dcm][ddd]
{
dcTemps
= dc[dcm][ddd];
dc[dcm][ddd]
= dc[dcm][eee];
dc[dcm][eee]
= dcTemps;
}
}
}
for(dcm=0;dcm
{
for(ddd=0;ddd
{
cout
<< dc[dcm][ddd] << " ";
cout
<< "\n";
}
}
break;
default:
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "Error: Please try again enter 1 or 2 only! \n";
break;
}
break;
default:
system("cls");
cout
<< "************ WELCOME TO ARRAY PROJECT CONSOLE **********
\n";
cout
<< "Error: Please try again enter 1 or 2 only! \n";
break;
}
cout
<< "\n Try Again? \n[Y] Yes, [N] No \n" ;
cout
<< "\nEnter: ";
cin
>> tryAgain;
}while((tryAgain
!= 'N')&&(tryAgain != 'n'));
cout
<< "\n *** THANK YOU :) *** \n";
system("PAUSE");
return
EXIT_SUCCESS;
}
Mga Komento
Mag-post ng isang Komento