السلام عليكم ورحمة الله وبركاته
اخوتي الكرام اخواتي الفاضلات
سؤالنا اليوم يقول:
اكتب برنامج بلغة سي بلس بلس لتوليد مصفوفة مكونة من 40 عدد صحيح ثم نقل العناصر التي قيمتها اقل او تساوي 50 الى مصفوفة ثانية ثم ترتيب كل من المصفوفتين بأستخدام ترتيب الحشر
Insertion sort
الحل في ادناه:
The code:
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int MatGen(int a[40])
{int i;
/* initialize random seed: */
srand (time(NULL));
// generate 40 random numbers between 1 and 100 and put them in the matrix a
for (i=0;i<40;i++)
a[i]=rand()%100 +1;
}
int cond(int a[40],int b[40])
{int i;
for (i=0;i<40;i++)
{
if (a[i]<=50)
b[i]=a[i];
else b[i]=0;
}
}
void selectSort(int arr[40])
{
//pos_min is short for position of min
int pos_min,temp;
for (int i=0; i < 39; i++)
{
pos_min = i;//set pos_min to the current index of array
for (int j=i+1; j < 40; j++)
{
if (arr[j] < arr[pos_min])
pos_min=j;
//pos_min will keep track of the index that min is in, this is needed when a swap happens
}
//if pos_min no longer equals i than a smaller value must have been found, so a swap must occur
if (pos_min != i)
{
temp = arr[i];
arr[i] = arr[pos_min];
arr[pos_min] = temp;
}
}
}
int print (int arr[40])
{
int i;
for (i=0;i<40;i++)
cout<<arr[i]<<“\t”;
}
int main()
{int i,a[40],b[40];
//the original matrix
cout<<“the original matrix”<<endl;
MatGen(a);
print(a);
cout<<endl;
//the second matrix
cout<<“the second matrix”<<endl;
cond(a,b);
print(b);
cout<<endl;
//the sorted original matrix
cout<<“the sorted original matrix”<<endl;
selectSort(a);
print(a);
cout<<endl;
//the sorted new matrix
cout<<“the sorted second matrix”<<endl;
selectSort(b);
print(b);
return 0;
}
The execution results:
اتمنى ان يكون السؤال وحله مفيداً ومفهوماً للجميع
تحياتي وانتظرونا في سؤال وجواب اخر قريباً ان شاء الله
thanks.please help me to solve this soon if possible Suppose you are blocking the left lane while driving a car and there is an angry driver behind you. Now suppose we can calculate the probability that the angry driver will flash their lights at you by looking at your car’s license plate number (CLP). Assume our calculation method takes two inputs: (i) NUM = Number of digits in the CLP. (e.g. 11228 has 5 digits) (ii) DIFF = Number of different digits represented by the CLP. (e.g. 11228 consists of 3 different digits: 1, 2, and 8)
Based on these inputs, assume the probability that a person will flash their light can be calculated as follows: Number of digits (NUM) Number of different digits (DIFF) Probability of Flashing Lights (PFL) NUM ≤ 4 DIFF ≤ 2 10% DIFF >2 20% NUM >4 DIFF ≤ 2 50% DIFF >2 80%
Now, write a proper C++ program that will take as input the license plate number CLP and output the probability of flashing lights as described by the table above. Your program should abide by the following requirements: 1- Must compile and run properly. 2- Must make sure the number of digits entered by the user does not exceed 6 and is more than 2 digits. Otherwise, must ask the user to re-enter the license plate number. 3- Must contain a function getDiff of the integer type that takes in one integer parameter CLP. The function should return the number of different digits in the CLP passed as an argument. 4- Must contain a function getNum of the integer type that takes in one integer parameter CLP. This function should return the number of digits that represent the CLP argument.
5- Your implementation of getDiff must make use of arrays.
إعجابإعجاب
this is amazing example but unfortunately I have no time now 😦
إعجابإعجاب
السلام عليكم ارجو مساعدتي ضروري لانكم درستم مادة المعماريه انوي ان اعمل محاكاة لمعماريتين مختلفتين في”FBGA heterogeneous architecture “ولا اعرف من اين ابدا اي ماهي التقنيه اوالبيئه التي ممكن ان اعمل بها
إعجابإعجاب
وعليكم السلام
هذا الموضوع كبير بمستوى بحوث تخرج او حتى دراسات عليا واما البداية فتكون من تحديد نوع الهاردوير المراد استخدامه واكثرها شيوعا هو xilinix
ويجب معرفة كيفية العمل على لغة ال vhdl
وبالتوفيق ان شاء الله
إعجابإعجاب
شكرا والله ايوفقك
إعجابإعجاب
العفو
إعجابإعجاب
من فضلك كنت عاوز كود او شرح عملية ادخال معادلات خطية عددها n وعدد المجاهيل n ايه الكود الي يرتب المجاهيل ويحلها ويطلعلي قيمة كل متغير كام
إعجابإعجاب
هناك برامج كثيرة تسمى
solvers
مكتوبة بلغة سي بلس بلس لحل هكذا انظمة من المعادلات وهذه بعض الامثلة لها:
http://www.cplusplus.com/forum/beginner/34039/
إعجابإعجاب
السلام عليكم بشمهندس مصطفي عنداستفسار بشأن حل معالادت عددهم n وعدد المجاهيل n يتم ادخال المعادلات ع طريق المستخدم ايه الكود الي يحل المعادلات دي ويطلع ناتج المتغيرات ويقولي في كام متغير مثال بسيط 1×1+4×2=9 &2×1-5×2=-8 المستخدم هيدخل المعادلات ازاي بقا اكتب كود يطلع قيم x1&x2 وازاي يقولي ان عدد المتغيرات 2
إعجابإعجاب
وعليكم السلام
تستطيع ادخال عدد المتغيرات كمتغير ايضاً في بداية البرنامج ثم وضعها في المعادلة بحسب المطلوب يعني كمثال
cout<<"Enter number of variables"<>count;
for (i=0;i>var[i];
if(count==1)
y=var[0];
else if (count==2)
y=var[0]+5*var[1];
وهكذا
طبعاَ هذا مجرد مثال ويمكنك ايجاد الكثير من الامثلة اونلاين او في الموقع هنا
إعجابإعجاب
السلام عليكم متاسف جدا استاذ مصطفي بس انا الحمد لله عديت مرحلة حلوة من الفكرةبس عندي مشكلة لو تقدر تساعدني فيها ازاي لو دخلت معادلة غير مترتبة زي كدا 2×1-2×3+4×2+x4=5 انا مدخلها string والمستخدم الي هيدخلها ازاي اعمل كود يرتبها ل2×1+4×2-2×3+x4=5 وازاي اخلي البرنامج يخرج معامل بتاع x3 مثلا وازاي يفهم معامل الوحدة لو مكتبتش واحد قدام المتغير
إعجابإعجاب
وعليكم السلام اخي الكريم
للأسف ليس عندي فكرة عن كيفية عمل ذلك
تحياتي لكم
إعجابإعجاب
متشكر جدا بشمهندس مصطفي وكل عام وانتا طيب ☺
إعجابإعجاب
وانت طيب اخي الكريم
إعجابإعجاب