Case13. O’quv masalalarini raqamini aniqlovchi 10-50 gacha butun son berilgan. Son kirirtilganda masala raqamini unga mos so’zlarda ifodalovchi dastur tuzilsin. (“yigirmanchi masala”, “o’ttiz beshinchi masala” va hk)
#include #include using namespace std;
int main(int argc, const char * argv[]) {
int n,a,b;
cout<<" n= "; cin>>n;
a = n/10;
b = n%10;
switch (a) {
case 1:cout<<"o`n";{
switch (b) {
case 0: cout<<"inchi masala\n"; break;
case 1: cout<<" birinchi masala\n"; break;
case 2: cout<<" ikkinchi masala\n"; break;
case 3: cout<<" uchinchi masala\n"; break;
case 4: cout<<" to`rtinchi masala\n"; break;
case 5: cout<<" beshinchi masala\n"; break;
case 6: cout<<" oltinchi masala\n"; break;
case 7: cout<<" yettinchi masala\n"; break;
case 8: cout<<" sakkizinchi masala\n"; break;
case 9: cout<<" to`qqizinchi masala\n"; break;
}
} break;
case 2:cout<<"yigirma";{
switch (b) {
case 0: cout<<"inchi masala\n"; break;
case 1: cout<<" birinchi masala\n"; break;
case 2: cout<<" ikkinchi masala\n"; break;
case 3: cout<<" uchinchi masala\n"; break;
case 4: cout<<" to`rtinchi masala\n"; break;
case 5: cout<<" beshinchi masala\n"; break;
case 6: cout<<" oltinchi masala\n"; break;
case 7: cout<<" yettinchi masala\n"; break;
case 8: cout<<" sakkizinchi masala\n"; break;
case 9: cout<<" to`qqizinchi masala\n"; break;
}
} break;
case 3:cout<<"o`ttiz";{
switch (b) {
case 0: cout<<"inchi masala\n"; break;
case 1: cout<<" birinchi masala\n"; break;
case 2: cout<<" ikkinchi masala\n"; break;
case 3: cout<<" uchinchi masala\n"; break;
case 4: cout<<" to`rtinchi masala\n"; break;
case 5: cout<<" beshinchi masala\n"; break;
case 6: cout<<" oltinchi masala\n"; break;
case 7: cout<<" yettinchi masala\n"; break;
case 8: cout<<" sakkizinchi masala\n"; break;
case 9: cout<<" to`qqizinchi masala\n"; break;
}
} break;
case 4:cout<<"qirq";{
switch (b) {
case 0: cout<<"inchi masala\n"; break;
case 1: cout<<" birinchi masala\n"; break;
case 2: cout<<" ikkinchi masala\n"; break;
case 3: cout<<" uchinchi masala\n"; break;
case 4: cout<<" to`rtinchi masala\n"; break;
case 5: cout<<" beshinchi masala\n"; break;
case 6: cout<<" oltinchi masala\n"; break;
case 7: cout<<" yettinchi masala\n"; break;
case 8: cout<<" sakkizinchi masala\n"; break;
case 9: cout<<" to`qqizinchi masala\n"; break;
}
} break;
case 5:cout<<"ellik";{
switch (b) {
case 0: cout<<"inchi masala\n"; break;
case 1: cout<<" birinchi masala\n"; break;
case 2: cout<<" ikkinchi masala\n"; break;
case 3: cout<<" uchinchi masala\n"; break;
case 4: cout<<" to`rtinchi masala\n"; break;
case 5: cout<<" beshinchi masala\n"; break;
case 6: cout<<" oltinchi masala\n"; break;
case 7: cout<<" yettinchi masala\n"; break;
case 8: cout<<" sakkizinchi masala\n"; break;
case 9: cout<<" to`qqizinchi masala\n"; break;
}
} break;
}
return 0;
2-laboratoriya
13. 1 dan N gacha bo'lgan ketma-ketlikda to'rtga karra bo’lgan sonlaring oxirgi uchtasining yig’indisini toping.
Berilgan radiusdan foydalanib aylananing uzunligini va doiraning yuzasini hisoblovchi funksiya yarating.Ushbu funksiya asosida r,r1,r2 radiuslar asosida hisoblang.
Berilgan sonning raqamlar yig’indisini hisoblovchi funksiya hosil qiling. Bu funksiya yordamida a,b,c sonlarini raqamlar yig’indisini hisoblang.
a)
#include
#include using namespace std;
void yuza(int r){
float l=0,s=0;
l = 2*M_PI*r;
s = M_PI*r*r;
cout<<"\n\naylana uzunligi : "<cout<<"doira yuzi: "<}