2-мustaqilta’limishhisoboti Fan- “Algoritmlarniloyihalash” Bajardi: Ergasheva Sevara Tekshirdi: Bobonazarov Akmal
Download 258.6 Kb.
|
Ergasheva
- Bu sahifa navigatsiya:
- 1-topshiriq. Quyidagi transsendent tenglamani oraliqni teng ikkiga bo’lish va oddiy iteratsiya usuli yordamida yechimini aniqlovchi dastur tuzing
- 3-topshiriq
1-Amaliy mashg‘ulotimavzusi: Algoritmlarni loyihalash. Algoritmkorrektvasamaradorliginibaholash.
Ishningmaqsadi:Berilganmasalalaruchunalgoritmtuzish, ularnibaholashkriteriyalaribo’yichatahlilqilish, qiyinlikdarajasinibaholashnio’rganish 1-topshiriq. Quyidagi transsendent tenglamani oraliqni teng ikkiga bo’lish va oddiy iteratsiya usuli yordamida yechimini aniqlovchi dastur tuzing: #include using namespace std; double f(double x) { return sin(x)/(pow(x*x*x+x*x,0.25))-3*cos(x); }
{ double a,b,c,e; cout<<"a va b sonlarni kiriting "; cin>>a>>b; cout<<"aniqlikni kiriting "; cin>>e; while (fabs(b-a)>=e) { c=(a+b)/2.0; if (f(a)*f(c)<0) b=c; else a=c; } c=(a+b)/2.0; cout<<"x ning qiymati "< 2-topshiriq : 5-masala. Ishlab chiqarish korxonasi ikki xil turdagi belkuraklar ishlab chiqaradi. Ularni tayyorlash uchun metall va yog‘och talab qilinadi. Birinchi turdagi belkurakni tayyorlash uchun 0.04 metall parchasi va 0.004 m3 yog‘och, ikkinchi turdagi belkurak uchun 0.02 metall parchasi va 0.004 m3 yog‘och talab etiladi. Birinchi turdagi belkurakning sotish narxi 60 so‘m, ikkinchi turdagi belkurakning narxi 50 so‘m. Bozorni o‘rganish natijasida 1-turdagi belkurakka talab 2-turdagi belkurakka nisbatan juda yuqori bo‘lib, oyiga 3000 donaga ko‘pni tashkil etadi. Bundan tashqari 2-turdagi belkurakka talab oyiga 15 ming donadan oshmaydi. Ishlab chiqarish korxonasida 300 ta metall parchasi va 60 m3 yog‘och mavjud bo‘lsa, ikkala turdagi belkuraklardan maksimal foyda olish uchun oyiga nechtadan ishlab chiqarishi kerak bo‘ladi? #include #include using namespace std; int main() { //Input Data cout<<"\n\nUzgaruvchilar sonini kiriting.."; int n; cin>>n; double x[n]; int ER; int c; cout<<"\n\nTenglamalar sonini kiriting.."; cin>>c; //total elements int t=n+c; double C[c][t+1]; //={0}; cout<<"\n\nSimplex jadval koeffitsentlarini kiriting"< } } double Zc[t]; //={0}; cout<<"\n\nMaqsad funksiya koeffitsenlarini kiriting.."; for(int i = 0; i } //Verification of the input data cout<<"\n\nThe Objective Function is Z = "; for (int i=0; i for (int i=n; i }
double Zsol[t+1]; //Zj array double Zfin[t]; double ratio_min; cout<<"\n\nZj = "; cout<<"\n\nCj - Zj = "; Zfin_max = Zfin[0]; else {
cout<<"\n\n\nMaximum value of Cj - Zj = "< //compute Ratio cout<<"\n\n\nRatio array is R = "; cout<<"\n\n\nMinimum value f ratio is "; for (int i=0; i cout< while(Zfin_max>0){ cout<<"\n\n\nIteration "< //Entering column and exiting row for(int j=0; j // cout<<"\n\nOther columns coeff are "; //compute Zj cout<<"\n\n\nZj = "; //re-assigning Zj to 0 for(int j=0; j<=t; j++){ cout<<"\n\n\nCj - Zj = "; Zfin_max = Zfin[0]; else {
cout<<"\n\n\nMaximum value of Cj - Zj = "< if(Zfin_max<0) { //compute Ratio cout<<"\n\n\nRatio array is R = "; cout<<"\n\n\nMinimum value f ratio is "; for (int i=0; i cout< iter++;
end:cout<<"\n\nPlease check ";
cout<<"\n\n\n"; for(int i=0; i cout< #include int main() { //Input Data cout<<"\n\nUzgaruvchilar sonini kiriting.."; //total elements double C[c][t+1]; //={0}; double Zc[t]; //={0}; cout<<"\n\nThe Objective Function is Z = "; for (int i=0; i for (int i=n; i }
double Zsol[t+1]; //Zj array double Zfin[t]; double ratio_min; cout<<"\n\nZj = "; cout<<"\n\nCj - Zj = "; Zfin_max = Zfin[0]; else {
cout<<"\n\n\nMaximum value of Cj - Zj = "< //compute Ratio cout<<"\n\n\nRatio array is R = "; cout<<"\n\n\nMinimum value f ratio is "; for (int i=0; i cout< while(Zfin_max>0){ cout<<"\n\n\nIteration "< //Entering column and exiting row for(int j=0; j // cout<<"\n\nOther columns coeff are "; //compute Zj cout<<"\n\n\nZj = "; //re-assigning Zj to 0 for(int j=0; j<=t; j++){ cout<<"\n\n\nCj - Zj = "; Zfin_max = Zfin[0]; else {
cout<<"\n\n\nMaximum value of Cj - Zj = "< if(Zfin_max<0) { //compute Ratio cout<<"\n\n\nRatio array is R = "; cout<<"\n\n\nMinimum value f ratio is "; for (int i=0; i cout< iter++;
end:cout<<"\n\nPlease check ";
cout<<"\n\n\n"; for(int i=0; i cout< Download 258.6 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling