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

By C : how to make factorial number ex: 3! please

مغلق
بدأه zekoxp في 9 نوفمبر 2003 · 4 رد · 865 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Salam 4 all

------------------

i have a sheet in the faculty i must give it tomorrow please help me:

-----------------------------------------------------------------------------------

1 - how to make factorial number for example 3! = 3 * 2 * 1 = 6

2 - if i throw a DICE or " zahrit El nard " 1000 times how much the number 3 will appear and how many time number 4 will appear foe HELP you can use the function Rand

please please thats is very important

------------------------------------------------------

My old USER NAME was : AL Mobarbeg Al 3arbi wrote by arabic

i will wate answering until The Fagr

#2

السلام عليكم اخوي ،،

هذا هو حل سؤالك الاول بس الثاني ما اقدر عليه و السموحه ..

#include<iostream>

using namespace std;

int main()

{

int f ,p = 1; ;

cout << "Please enter the number : ";

cin >> f;

for( int s = 1 ; s <=f ; s++)

{

p = p * s;

}

cout << "The fraction is = " << p << endl;

return 0 ;

}

اخوك تيمون :)

#3

Thank you very much

------------------------------

thank you for fast answering and i will try to find the next question

thanks again

Ramdan Kareem

#4

بسم الله الرحمن الرحيم

فى الحقيقة انا قرات هذا الموضوع متاخراً

لكن عندى اضافة فى شكل طريقة جديدة

يمكن ان تفيد فى المستقبل

int fact(int a)

{

if(a == 1) return 1;

return a*f(a-1);

}

هذه الطريقة تفتح باب

كبــــــــــــــــــــــــــير

Functions call it self!!!!!!!

ارجو اعلامى بريديا لمزيد من التفاصيل

#5

بالنسبة لحل السؤال الثاني فهو كالتالي :

// Roll a six-sided die 1000 times

#include <iostream.h>

#include <iomanip.h>

#include <stdlib.h>

main()

{

int frequency1 = 0, frequency2 = 0,

frequency3 = 0, frequency4 = 0,

frequency5 = 0, frequency6 = 0;

for (int roll = 1; roll <= 1000; roll++) {

int face = 1 + rand() % 6;

switch (face) {

case 1:

++frequency1;

break;

case 2:

++frequency2;

break;

case 3:

++frequency3;

break;

case 4:

++frequency4;

break;

case 5:

++frequency5;

break;

case 6:

++frequency6;

break;

}

}

cout << "Face" << setw(13) << "Frequency"

<< endl << " 1" << setw(13) << frequency1

<< endl << " 2" << setw(13) << frequency2

<< endl << " 3" << setw(13) << frequency3

<< endl << " 4" << setw(13) << frequency4

<< endl << " 5" << setw(13) << frequency5

<< endl << " 6" << setw(13) << frequency6 << endl;

return 0;

}

الحل يشمل جميع الأوجه من 1 الى 6 .

دعواتكم ...

هذا الموضوع مغلق.

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