• Rasm 28.Tarmoqlanuvchi jarayonning blok Sxemasi. Tarmoqlanuvchi dasturlarga misollar
  • Ixtiyoriy butun tok qiymati noldan katta bo’lsa tok bor yoki yoqligini hisoblash dasturini tuzing.
  • Shartli operatorga doir tarmoqlanuvchi algoritmga misol




    Download 15,08 Mb.
    bet43/135
    Sana22.05.2024
    Hajmi15,08 Mb.
    #250347
    1   ...   39   40   41   42   43   44   45   46   ...   135
    Bog'liq
    Fizik jarayonlarni kompyuterda modellashtirish

    Shartli operatorga doir tarmoqlanuvchi algoritmga misol.
    C++ tilida tarmoqlash operatoridan farqli shart bo’yicha o’zlashtirish (yoki shartli o‟zlashtirish) operatori ham bo‟lib, uning ko‟rinishi quyidagicha: o’zgaruvchi = (shart) ? ifoda1: ifoda2;
    Tarmoqlanuvchi algoritmga misol.
    Masala: Elektr zanjiridagi tok manbai klemmalaridagi kuchlanish U=100 v bo`lib, qarshiliklari R1=5 a va R2=4 a bo`lgan iste‟molchilar ketma-ket va parallel ulangan holda tok kuchlari qanday bo`lishini aniqlash dasturini tuzing.
    Misol dasturi:
    1 # include
    2 # include
    3 using namespace std;
    5 int main()
    6 {
    7 float R1,R2,R,I,U;
    8 string s;
    9 cout<<"Tok manbai klemmalaridagi kuchlanishni kiriting:=U”;
    10 cin>>U;
    11 cout<<"Birinchi istemolchi qarshiligini kiriting:=R1”;
    12 cin>>R1;
    13 cout<<"Ikkinchi istemolchi qarshiligini kiriting:=R2”;
    14 cin>>R2;
    15 cout<<"Istemolchilar ulanish turini kiriting:=s”;
    16 cin>>s;
    17 if (s=="parallel")
    18 {
    19 R=R1*R2/(R1+R2); I=U/R;
    20 }
    21 if (s=="ketmaket")
    22{
    23 R=R1+R2; I=U/R;
    24 }
    25 cout<<"Istemolchilar "<

    C++da

    Pythonda

    Ixtiyoriy butun tok qiymati noldan katta bo’lsa tok bor yoki yoqligini hisoblash dasturini tuzing.

    1 # include
    2 # include
    3 using namespace std;
    4 int main()
    5{
    6 int i;
    7 cout<<(“tok kuchini kiriting: i=”)

    8 if (i>0))


    9 cout<<(“Tok kuchi bor ”)
    else
    10 cout<<(“Tok kuchi yo’q”);
    11 return 0;
    12 }



    1 print (‘i tok kuchi qiymatini kiriting’)


    2 i=int(input())
    3 if i>0:
    4 print(‘tok kuchi bor’)
    else
    5 print(‘tok kuchi yo’q’)


    Download 15,08 Mb.
    1   ...   39   40   41   42   43   44   45   46   ...   135




    Download 15,08 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Shartli operatorga doir tarmoqlanuvchi algoritmga misol

    Download 15,08 Mb.