الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

بليز مساااعده

بدأه صعب تكراري في 18 نوفمبر 2011 · 5 رد · 1,057 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

اخباركم......

بليز ساعدوني الدكتوره اعطتنا واجب في البرمجه وحليته بس ماني متاكده من الحل

اتمنى اللي عنده خلفيه عن البرمجه يحله ,,,, لان array و functionماني فاهماها

1:write three function to find sum, maximum,minimum of arry element

*array size &arrat element given by user

انا حليت ماني متاكده صح او خطاوهذا الحل

#include<iostream.h>

int sum(int[]);

int min(int[]);

int max(int[]);

void main()

{

int a[4];

for(int i=0;i<4;i++)

cout<<"sum="<<sum(a)<<"\n";

cout<<"min="<<min(a)<<"\n";

cout<<"max="<<max(a)<<"\n";

}

int sum(int a[])

{

for(int i=0;i<4;i++)

sum=sum+ a;

return 0;

}

int min(int a[])

{

for(int i=0;i<4;i++)

if (a<min)

min=a;

return 0;

}

int max(int a[])

{

for(int i=0;i<4;i++)

if (a<max)

max=a;

return 0;

}

}

2:write program to modify array valu decrement 3 from array element

array element given by userbut must between (5-60)rray size is define in program

وجزاكم الله الف خير

#2

التالى حل السؤال اﻻول:

بما أن عدد المدخلات يحدد بواسطة المستخدم ﻻ يفيد استخدام مصفوفة ثابتة الحجم كــ: arra[10];s

وبالتالى تم استخدام

المشكلة ان تكونو لم تدرسو المؤشرات وnew و delete

تم اختبار الكود على بيئة تطوير كود بلوك 10.05

الكود

واكود مرفق ايضا

//1.write three function to find sum, maximum,minimum of arry element
//array size & element given by user
#include <iostream>
using namespace std;
int aSum(int[], int);
int aMin(int[], int);
int aMax(int[], int);

int main()
{
    int aCounter = 0;
    //pointer to array
    int *aArray;
    //// Ask user How many elements to process
    cout << "Pls enter: How many numbers u want to find \n sum, min and max for them. : ";
    cin >> aCounter;
    ///// now dynamically allocate mem for array that user entered ...
    aArray = new int[aCounter];
    /// now ask user to input the elemnts to arry:
    /// the user must inter all items
    for(int i = 0; i< aCounter; i++)
    {
        cout << "Enter item " << i+1 << " of " << aCounter << ": ";
        cin >> aArray;
    }
    /// print out the input data and sum etc ..
    cout << "u entred the fowllowing: "<< endl;
    for(int i = 0; i < aCounter; i++)
        cout <<  aArray << endl;
    // print out sum of items entred:
    cout <<endl <<"items sum: " << aSum(aArray, aCounter) << endl;
    cout << "item min: " << aMin(aArray, aCounter ) << endl;
    cout << "items max: " << aMax(aArray, aCounter) << endl;
    delete aArray;
    return 0;
}

int aSum(int a[], int n)
{
    int temp = 0;
    for(int i=0; i < n; i++)
        temp += a;
    return (temp);
}


int aMin(int a[], int n)
{
    int temp = 0;
    int nmin = a[0];
    for(int i = 0; i < n; i++)
        if (nmin > a)
        {
           temp = a;
           nmin = temp;
        }
    return nmin;
}

int aMax(int a[], int n)
{
    int temp = 0;
    int nmax = a[0];
    for(int i = 0; i < n; i++)
        if (nmax < a)
        {
           temp = a;
           nmax = temp;
        }
    return nmax;
}

q1.cpp

تم تعديل هذه المشاركة بواسطة محمد ابوزايد في 18 نوفمبر 2011 في 10:07

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#3

وهذا حل التدريب الثانى

/*
2:
write program to modify array value decrement 3 from array element
array element given by user input must between (5-60) array size is define in program


*/
#include <iostream>
using namespace std;


int main()
{
    int aCounter = 0;
    int aArray[5] = {0}; // set all array elements to 0 (array initilizatin)
    //// Ask user How many elements to process
    cout << "Pls enter: num between 5 and 10 : ";
    cout << "enter 0 or less than 5 or " << endl << "greater thn 10 to continue ..: "<< endl;

    /// now ask user to input the elemnts to arry:
    /// the user must inter all items
    int i = 0;
    for(i = 0; i< 5; i++)
    {
        cout << "Enter item " << i+1 << " of " << 5 << ": ";
        int temp = 0;
        cin >> temp;
        if (temp < 4 || temp > 11)
            break;
        else
            aArray = temp;
    }
// now decrement each element by 3
    while (i--)
    {
        aArray-=3; // or aArray = aArray-3
        cout << endl << aArray;
    }

    return 0;
}

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#4

مشكوووووور اخوي

وجزاك الله الف خير

لم ندرس المؤشرات وnew و delete

بس كيف اكتب السؤال والاجابه في البرناااااامج واطبعه زي الحل الي فوق

لان الدكتوره طلبت1: كتابه السؤال والجواب .

2:اسم الماده في تذييل كل صفحه

في نفس البرنامج

...................

هل اكتب البرنامج في c++

بعدين انقله للورد

واكتب السؤال..واسم الماده

واطبعه

او كيف؟؟؟؟؟؟

واكرر شكري لك

تم تعديل هذه المشاركة بواسطة صعب تكراري في 18 نوفمبر 2011 في 17:31

#5

محمد ابو زيد كفى و وفى

فقط اضافة بسيطة لكود اخي محمد ابو زيد

وهو قبل جملة


;return 0

في الـ main

اضف الكود التالي حتى تتمكن من مشاهدة الناتج

system("pause");

======

ايضا يتوجب عليك كتابة الكود كاملا + الـ output

#6
اقتباس
مشكوووووور اخوي

وجزاك الله الف خير

لم ندرس المؤشرات وnew و delete

السؤال اﻻول بدون مؤشرات ووnew و delete

//1.write three function to find sum, maximum,minimum of arry element
//array size & element given by user
#include <iostream>
using namespace std;
int aSum(int[], int);
int aMin(int[], int);
int aMax(int[], int);

int main()
{
    int aCounter = 0;
    int temp = 0;
    //pointer to array
    int aArray[100] = {0};
    //// Ask user How many elements to process
    cout << "Pls enter: How many numbers u want to find";
    cout << "\n sum, min and max for them. : ";
    cout << "\n the items must be from 1 to 100: " << endl;
    //cin >> aCounter;
    /// the user must inter all items
    int i = 0;
    do
    {
        cout << "Enter item or 0 to exit : " << i+1 << ": ";
        cin >> temp;
        aArray[i++] = temp;
        aCounter++;
    }
    while( temp != 0 || i > 99);
        aCounter--;

    /// print out the user input data and sum etc ..
    if (aCounter != 0)
    {
        cout << "u entred the fowllowing: "<< endl;
        for(int i = 0; i < aCounter; i++)
            cout <<  aArray << endl;
        // print out sum of items entred:
        cout <<endl <<"items sum: " << aSum(aArray, aCounter) << endl;
        cout << "item min: " << aMin(aArray, aCounter ) << endl;
        cout << "items max: " << aMax(aArray, aCounter) << endl;
    }
    system("pause");
    return 0;
}

int aSum(int a[], int n)
{
    int temp = 0;
    for(int i=0; i < n; i++)
        temp += a;
    return (temp);
}


int aMin(int a[], int n)
{
    int temp = 0;
    int nmin = a[0];
    for(int i = 0; i < n; i++)
        if (nmin > a)
        {
            temp = a;
            nmin = temp;
        }
    return nmin;
}

int aMax(int a[], int n)
{
    int temp = 0;
    int nmax = a[0];
    for(int i = 0; i < n; i++)
        if (nmax < a)
        {
            temp = a;
            nmax = temp;
        }
    return nmax;
}

اقتباس
بس كيف اكتب السؤال والاجابه في البرناااااامج واطبعه زي الحل الي فوق

لان الدكتوره طلبت1: كتابه السؤال والجواب .

2:اسم الماده في تذييل كل صفحه

في نفس البرنامج

لو نسخنا الكود فى ورقة وورد اتجاة الصفحة فيها من اليسار الى اليمن كل شئ سيكون على ما يرام.

واضافة اسم المادة فى تزييل صفة الورد .........

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

مواضيع مشابهة