سلام دوستان. اگه یه لطفی بکنید کار این برنامه رو به بهترین شکل،حرفه ای ترین شکل،جدید ترین شکل و بهینه ترین شکل ممکن بنویسید
میخوام فرقشون رو ببینم
کاری با کامنت هاش نداشته باشید اونا الکین D:
#include<iostream>					//cout , cin , ...#include<conio.h>					//getch() , ...
#include<iomanip> //setw() , fixed , setprecision , ...
#include<cstdlib> //_sleep(0)


using namespace std; //standard namespace
void inputer(float a[],int len){ //THIS IS GETTING YOU ARRAY
for(int i=0;i<len;i++){ //for loop, it can repeat and get a new number
cout<<" "<<i+1<<"."<<" Array[ "<<i<<" ] = ";
cin>>a[i]; //reciver numbers
}
}
void shower(float a[],int len){ //THIS CAN SHOW ARRAY
for(int i=0;i<len;i++) //for loop, it can repeat and show next number
cout<<a[i]<<" "; //setw(4) , 4 interval
cout<<endl;
}
void bubblesort (float a[],int len){ //IT SORT ARRAY
int hold; //hold , it can hold for moving to numbers of array
for(int p=0;p<len-1;p++) //for loop, repeat next for loop
for(int j=0;j<len-1;j++)
if(a[j]>a[j+1]){ //if a number is larger than another number, move they
hold=a[j];
a[j]=a[j+1];
a[j+1]=hold;
}
}
void getmedian(float a[],int len){ //IT CAN GET MIDDLE OF ARRAY
cout<<a[len/2];
}
void average(float a[],int len){ //IT CAN GET AVERAGE OG ARRAY
int sum=0;
for(int i=0;i<len;i++)
sum+=a[i];
/* cout<<"How many does your answer continue to deciaml : ";
int n;
cin>>n;
cout<<"\nAverage = "<<static_cast<double>(sum)/len;
cout<<fixed<<setprecision(n);*/ //setprecision, show up to 4 decimal place. static_cast, it changes integer number to decimal number
cout<<"\n\n Average = "<<fixed<<static_cast<double>(sum)/len;
}
/*void mode(int a[],int len){
int f[10]={0};
for(int i=0;i<len;i++)
++f[a[i]];
int max=f[0];
int index=0;
for(int j=1;j<=9;j++)
if(f[j]>max){
max=f[j];
index=j;
}
cout<<"\n\n Mode = "<<a[f[index]];
}*/
main(){ //main function
system("color e");
cout<<" Welcome, This program can get average and middle of numbers in the array"<<endl;
_sleep(2000);
system("color 9");
cout<<" OK, It's enough"<<endl;
_sleep(2000);
system("color c");
cout<<" Let's start"<<endl;
_sleep(2000);

zer0:system("cls");

system("color f");

cout<<" Enter size of array : ";
int size;
cin>>size; //GET SIZE OF ARRAY

if(size==0){
system("color c");
_sleep(100);
cout<<"\a\n You should input a number bigger than '0'";
_sleep(1500);
cout<<"\n\n\a Try again\n\n";
_sleep(1000);
goto zer0;
}

float a[size];

inputer(a,size); //GET NMUBERS OF ARRAY

cout<<endl<<" Your array : ";
shower(a,size); //SHOW NUMBERS OF ARRAY

_sleep(500);

cout<<endl<<" Your sorted array : ";
bubblesort(a,size); //SORT ARRAY
shower(a,size); //SHOW NEW SORTED ARRAY

_sleep(500);

cout<<endl<<" Median = ";
getmedian(a,size); //GET MIDDLE OF ARRAY

_sleep(500);

average(a,size); //GET AVERAGE OF ARRAY

// mode(a,size);

cout<<"\n\n";

char pm[43]=" This is your information that you entered";

for(int sh=0;sh<43;sh++){
cout<<pm[sh];
_sleep(20);
}
cout<<"\n\n";

char pm2[18]=" Hope to meet you";

for(int sh=0;sh<18;sh++){
cout<<pm2[sh];
_sleep(20);
}

cout<<"\t\t\t\t\t\t";

char pm3[14]="desined by AA";

for(int sh=0;sh<14;sh++){
cout<<pm3[sh];
_sleep(20);
}

getch();
}