Chiziqli algoritmga misol


Download 7.81 Kb.
Sana23.04.2023
Hajmi7.81 Kb.
#1389242
Bog'liq
Chiziqli algoritmga misol


Chiziqli algoritmga misol.
Masala: Elektr zanjiridagi iste‟molchi qarshiligi R=8 om, tok kuchi I=2 amper, tok manbaining ichki qarshiligi r=1 om bo`lsa, tok manbai klemmalaridagi kuchlanishni, tok manbaining ichki kuchlanishini va elektr yurutuvchi kuchni xisoblash dasturini tuzing.
Misol dasturi:
# include
using namespace std;
int main()
{
float R,r,I,U,u,E;
cout<<"Istemolchi qarshiligini kiriting:"<cin>>R;
cout<<"Tok manbai ichki qarshiligini kiriting:"<cin>>r;
cout<<"Zanjirdagi tok kuchini kiriting:\n";
cin>>I;
U=I*R;
u=I*r;
E=I*(R+r);
cout<<"Tok manbai klemmalaridagi kuchlanish="<cout<<"Tok manbaidagi ichki kuchlanish="<cout<<"Zanjirdagi elektr yurutuvchi kuch="<}

2-Misol. Berilgan N (1≤N≤7) butun songa mos hafta kunini chiqaring. Yechim. Bu masalani yechish uchun tanlash operatoridan foydalanish kerak bo’ladi:


#include
using namespace std;
int main () {
int n;
cout << "N=";
cin >> n;
switch (n){
case 1: cout<< "Dushanba"; break;
case 2: cout<< "Seshanba"; break;
case 3: cout<< "Chorshanba"; break;
case 4: cout<< "Payshanba"; break;
case 5: cout<< "Juma"; break;
case 6: cout<< "Shanba"; break;
case 7: cout<< "Yakshanba"; break;
default: cout << "Adashdingiz!" ;
}
return 0;
}

Download 7.81 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling