Mavzu:STATIK MA'LUMOTLAR TUZILMALARINI O'RGANISH. MA’LUMOTLARNING ODDIY SOZLANGAN TOIFALARI. Topshiriq-1. Variant-10.
Masalaning berilishi. Talabalar ism-familiyasi, yoshi va ballaridan iborat jadval yarating va talabalarni ism-familiyasini alfavit bo‘yicha tartibga keltiring. (Jadval yaratishda strukturadan foydalaning).
Dastur kodi: #include
using namespace std;
struct talaba{
string FI;
int yoshi;
int ball;
};
int main(){
int n;
cout<<"Talabalar sonini kiriting: ";
cin>>n;
talaba a[n];
for (int i=0; i
cin.ignore();
cout<<"Familiya ismi: ";
getline(cin,a[i].FI);
cout<<"Yoshi: ";
cin>>a[i].yoshi;
cout<<"Ball: ";
cin>>a[i].ball;
}
for (int i=n-1; i>=0; i--){
cout<<"Familiya ismi: "<
cout<<"Yoshi: "<
cout<<"Balli: "<
}
return 0;
}
Dastur natijasi:
Topshiriq-2. Variant-25.
Masalaning berilishi. . Berilgan satrdagi sonlar yig‘indisini aniqlang.
Dastur kodi: #include
using namespace std;
int main(){
int s=0;
string str;
char a;
getline (cin,str);
for(int i=0; i
a=str[i];
if(isdigit(a))s+=((int)a-48);
}
cout<