2-3-mavzu: Strukturalar va massivlar. Abstrakt turlarni tasvirlash


fraction sub ( fraction dr1, fraction dr2, fraction * pdr)


Download 16.77 Kb.
bet3/3
Sana22.12.2022
Hajmi16.77 Kb.
#1043725
1   2   3
Bog'liq
2-3-amaliyot

}

fraction sub ( fraction dr1, fraction dr2, fraction * pdr)


{

fraction dr;


dr. numerator = dr1.numerator * dr2.numerator- dr2.numerator * dr1.denominator;

dr. denominator = dr1.denominator* dr2.denominator; return dr;


}

fraction mult ( fraction dr1, fraction dr2 )


{

fraction dr;


dr.numerator = dr1.numerator * dr2.numerator;

dr. denominator = dr1.denominator * dr2.denominator; return dr;


}

fraction divide ( fraction d1, fraction d2)


{

fraction dr;


dr.numerator = d1. numerator * d2. denominator; dr.denominator = d1. denominator * d2. numerator; return dr;

}


int main()

{


fraction a,b,c,d; fraction p;

printf("\n Kasr kiriting"); a = input();


b = input(); c = add(a,b);

out(c);


c = mult(a,b);

out(c);


c = divide(a,b); out(c);

return 0;

Amaliy masalalar.


  1. Student (ismi, tug’ilgan yili, GPA bali) strukturasini yarating. Struktura turidagi massiv yarating.

Ko’rsatilgan raqamli elementni olib tashlang va ko’rsatilgan familiyali elementdan so’ng element qo’shing.

  1. Avtosalon (markasi, rangi, narxi) strukturasini yarating. Struktura turidagi massiv yarating.

  2. Mamlakat (nomi, poytaxti, axoli soni, egallagan maydoni) strukturasini yarating. Struktura turidagi massiv yarating. Ko’rsatilgan aholi sonidan kichik bo’lgan elementni olib tashlang va ko’rsatilgan nomga ega bo’lgan elementdan so’ng element qo’shing.

  3. Davlat (nomi, davlat tili, pul birligi, valyuta kursi) strukturasini yarating. Struktura turidagi massiv yarating. Ko’rsatilgan nomga ega bo’lgan elementni o’chiring va fayl oxiriga ikkita element qo’shing.

  4. Tikuv fabrikasi (mato, narxi, rangi) strukturasini yarating. Struktura turidagi massiv yarating. Narxi bo’yicha mato turini saralang.

Download 16.77 Kb.

Do'stlaringiz bilan baham:
1   2   3




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