00AR00
AmeR NajjaR

project

شرح البرنامج

المشروع عبارة عن دمج لعدة برامج مختلفة المهام
1- حساب العاملي

2- حساب المتوسط الحسابي لعدد غير محدد

3- حل معادلة من الدرجة الثانية
(حل حقيقي+ حل عقدي
)



4-  المصفوفات
مصفوفتين ثنائيتين كل منهما 3 اسطر و3 اعمدة
تعبئة مصفوفة من المستخدم او عشوائي ضمن مجال يحدده المستخدم
عمليات حسابية جمع وطرح عادي للمصفوفات
اضافة الى عملية الضرب الجبري للمصفوفتين (ضرب سطر بعمود).ا






نأمل ان يعجبكم


الكود:
archive.org/download/project_201605/project.cpp
#include<iostream.h>
#include<stdlib.h>
#include<iomanip.h>
#include<math.h>

void GoAverage();
void GoX1X2();
void GoFactorial();
    int fact(int);
void GoMatrix();
    void printMatrix(double x[3][3]);
    void RandomMatrix(double x[3][3]);
    void CinMatrixa(double a[3][3]);
    void CinMatrixb(double b[3][3]);
void main()
{
cout<<"welcome to our program\ncreated by (AmeR)(Besher)(Hesham)\n\n";///////////AAAAAAAAAAAAAAAA
cout<<"----------------------------------\n";
int use;
while (1){
    cout<<"what do you want to do ?\n1-to calculate factorial:\t{ n! }.\n2-to calculate Average:\t\t{ (a1+a2+a3+.......+an)/n }.\n3-to Solve for X  :\t\t{ aX^2 + bX + c=0 }.\n4-to calculations on Arrays \t{ a[3][3] + - or * b[3][3] }.\n0-to exit\n";
    cin>>use;
    cout<<"----------------------------------\n";
    switch (use){
    case 1:
        GoFactorial();
        break;
    case 2:
        GoAverage();
        break;
    case 3:
        GoX1X2();
        break;
    case 4:
        GoMatrix();
        break;
    default :
        cout<<endl;
    }//end switch
    if (use == 0) break;}//end while
}//end main
/////////////////////////////////////////////////////////////
void GoFactorial()
{
    cout<<"Factorial:\n";
    int n;
    while(1){
        cout<<"Enter number (x)!:";
        cin>>n;
        if (n>=0 && n<32) {cout<<"**********\n"<<n<<"!="<<fact(n)<<"\n**********"<<endl; break;}
        else cout<<"please enter positive number and less than 32!\n";}//while
        
cout<<"\n----------------------------------\n";
system("pause");

}
int fact(int x)
{
    if (x==0 || x==1 )
        return 1;
    else return x*fact(x-1);


}
//////////////////////////////////////////////////
void GoX1X2()
{
    cout<<"(aX^2+bX+c=0):\n";
    double a,b,c,Delta,x1,x2;
    cout<<"a=";
    cin>>a;
    cout<<"b=";
    cin>>b;
    cout<<"c=";
    cin>>c;
    Delta=b*b-4*a*c;
    if (Delta > 0)
        {
        x1=(-b+sqrt(Delta))/(2*a);
        x2=(-b-sqrt(Delta))/(2*a);
        cout<<"X1= "<<x1<<endl;
        cout<<"X2= "<<x2<<endl;
        }
    else if (Delta == 0)
        {
        x1=(-b)/(2*a);
        cout<<"X1=X2= "<<x1<<endl;
        }
        else if (Delta < 0)
        {
    
        x1=(-b+sqrt(Delta))/(2*a);
        x1=(-b-sqrt(Delta))/(2*a);
        cout<<"X1= "<<-b/(2*a)<<'+'<<sqrt(fabs(Delta))/(2*a)<<" "<<'i'<<endl;
        cout<<"X2= "<<-b/(2*a)<<'-'<<sqrt(fabs(Delta))/(2*a)<<" "<<'i'<<endl;
        }
        cout<<"\n----------------------------------\n";
}
///////////////////////////////////////////////////////////
void GoAverage()
{
    cout<<"Average:\n(a1+a2+....+an)/n\n(9999 to end)\n";
    int i=0;
    double max=0,x;
    do{
        cout<<"Enter a"<<i+1<<":";
        cin>>x;
        if (x==9999) break;
        else max+=x;
        i++;}
    while(x!=9999);
    cout<<"*********\nAverage ="<<max/i;
cout<<"\n**********\n----------------------------------\n";
}
////////////////////////////////////////////////////////////
void RandomMatrix(double x[3][3])
{int n;
cout<<"from 1 to :";
cin>>n;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
x[i][j]=(rand()%n)+1;
}
/////////////////////////
void CinMatrixa(double a[3][3])
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++){
        cout<<"Enter a["<<i<<"]["<<j<<"]=";
        cin>>a[i][j];}
cout<<endl;
}

void CinMatrixb(double b[3][3])
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++){
        cout<<"Enter b["<<i<<"]["<<j<<"]=";
        cin>>b[i][j];}
cout<<endl;
}
//////////////////////////
void printMatrix(double x[3][3])
{
        for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
        cout<<setw(8)<<x[i][j];
        cout<<endl;}
cout<<endl;
}
//////////////////////////
void GoMatrix()
{
    double a[3][3],b[3][3],c[3][3]={0};
    cout<<"Matrix:\na[3][3] ? (+,-,*) b[3][3] = c[3][3]\n\n";
    cout<<"for matrix a[3][3]?\n";
    int user;
    cout<<"1-to enter manual values.\n2-to enter Random values.\n";
    cin>>user;
    if (user == 2) RandomMatrix(a);
    else CinMatrixa(a);
    cout<<"a[3][3]=\n";
    printMatrix(a);
    
    cout<<endl<<endl;
    
    cout<<"for matrix b[3][3]?\n";
    cout<<"1-to enter manual values.\n2-to enter Random values.\n";
    cin>>user;
    if (user == 2) RandomMatrix(b);
    else CinMatrixb(b);
    cout<<"b[3][3]=\n";
    printMatrix(b);
    
    cout<<endl<<"-------------------------"<<endl;
    int i,j,t;
    char ch;
    cout<<"what do you want to do?\nEnter + , - or *\n";
    cin>>ch;
    if (ch == '+') {
        for (i=0;i<3;i++)
        for (j=0;j<3;j++)
    c[i][j]=a[i][j]+b[i][j];}
    else if (ch == '-') {
        for (i=0;i<3;i++)
        for (j=0;j<3;j++)
    c[i][j]=a[i][j]-b[i][j];}
    else if (ch == '*') {
        for (i=0;i<3;i++)
        for (t=0;t<3;t++)
        for (j=0;j<3;j++)
    c[i][t]=c[i][t]+a[i][j]*b[j][t];}
    cout<<endl<<"c[3][3]=\n";
    printMatrix(c);
    cout<<"\n----------------------------------\n";
}
//////////////////////
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free