O’zbekiston Respublikasi axborot texnalogiyalari
Va kommunikatsiyalarini rivojlantirish vazirligi
Muhammad Al-Xorazmiy nomidagi
Toshkent axborot texnalogiylari universiteti
Talabasi Abdunazarov Vohidning
Dasturlash fanidan
4-Labaratoriya ishi
Bajardi 830-21 guruh talabasi
Abdunazarov Vohid 001 patok
2-Jadval
3. Firmaning xodimlarining to‟g‟risida (familiya, ismi, ish haqi, jinsi) ma‟lumot mavjud. Eng yuqori maosh oluvchi ayol haqida ma‟lumotlarni chiqaring.
#include
using namespace std;
class ishchilar
{
public:
string familyasi;
string ismi;
string jinsi;
int yoshi;
int ish_haqqi;
};
int main(){
ishchilar ob1, ob2, ob3 ,ob4, ob5;
ob1.familyasi="Abdunazarov ";
ob1.ismi="Vohidbek";
ob1.jinsi="Erkak";
ob1.yoshi=18;
ob1.ish_haqqi=500;
ob2.familyasi="Ubaydullayev";
ob2.ismi="Anvar";
ob2.jinsi="Erkak";
ob2.yoshi=22;
ob2.ish_haqqi=100;
ob3.familyasi="Rahimov";
ob3.ismi="Asror";
ob3.jinsi="Erkak";
ob3.yoshi=20;
ob3.ish_haqqi=50;
ob4.familyasi=" Toshmatov";
ob4.ismi=" Salim";
ob4.jinsi="Erkak";
ob4.yoshi=18;
ob4.ish_haqqi=400;
ob5.familyasi="Hamroyev";
ob5.ismi="Laziz";
ob5.jinsi="Erkak";
ob5.yoshi=18;
ob5.ish_haqqi=300;
cout<<"ishchinig familyasi "<cout<<"ismi "<cout<<"jinsi "<cout<<"ish haqqi "<cout<<"ishchinig yoshi "<
cout<
cout<<"ishchinig familyasi "<cout<<"ismi "<cout<<"jinsi "<cout<<"ish haqqi "<cout<<"ishchinig yoshi "<cout<cout<<"ishchinig familyasi "<cout<<"ismi "<cout<<"jinsi "<cout<<"ish haqqi "<cout<<"ishchinig yoshi "<cout<cout<<"ishchining familyasi "<cout<<"ismi "<cout<<"jinsi "<cout<<"ish haqqi "<cout<<"ishchinig yoshi "<cout<cout<<"ishchinig familyasi "<cout<<"ismi "<cout<<"jinsi "<cout<<"ish haqqi "<cout<<"ishchinig yoshi "<cout<int max,a[5]={ob1.ish_haqqi,ob2.ish_haqqi,ob3.ish_haqqi,ob4.ish_haqqi,ob5.ish_haqqi};
for(int i=0;i<=4;i++){
max=ob1.ish_haqqi;
if(max
max=a[i];}
cout<<"max="<return 0;
}
3-Jadval
3. Satrni teskarisini topadigan dastur tuzing.
#include
#include
using namespace std;
int main(){
int n;
char a[100];
gets(a);
int s=strlen(a);
for(int n=s;n>=0;n--)
{
cout << a[n] ;
}
cout<< endl;
return 0; }
1-Jadval
3. Uchburchak sinfi yaratilsin va konstruktor e‟lon qilinsin. Unda kamida uchta maydon va ularni ekranga chiqaruvchi va qayta ishlovchi sinf metodlarini yarating.
#include
#include
using namespace std;
class Uchburchak {
float a, b, c;
public:
Uchburchak() {
cout << "Uchburchak tomonlari: " << endl;
}
Uchburchak(float k, float t,float l) {
cout << "Perimetri: " << k << endl;
cout<<"O'rta perimetri:"<cout << "Yuzasi: " << l << endl;
}
};
int main() {
float a, b,c, p,m;
float s;
Uchburchak();
cout << "a="; cin >> a;
cout << "b="; cin >> b;
cout << "c="; cin >> c;
p = (a + b +c);
m=(a+b+c)/2;
s=sqrt(m*(m-a)*(m-b)*(m-c));
Uchburchak(p, m,s);
return 0;
}
6-Jadval
3. input faylida berilgan natural n sonining faktorialini output fayliga yozish dasturini tuzing.
#include
#include
#include
#include
using namespace std;
int main()
{
ofstream yozish;
yozish.open("input.txt");
int n;
cin>>n;
yozish< yozish.close();
ifstream oqi;
string satr;
char a[100];
int b;
oqi.open("input.txt");
if(!oqi.is_open()){
cout<<"Xatolik!"< }
getline(oqi,satr);
strcpy(a,satr.c_str());
b = atoi(a);
cout< oqi.close();
ofstream yozish2;
int fakt=1;
yozish2.open("output.txt");
for(int i=1;i<=b;i++)
{
fakt*=i;
}
yozish2<}
5-Jadval
3 Berilgan nomdagi matnli faylni yaratish va unga ixtiyoriy so‟z kiritish dasturini tuzing. Uni palindromlikka tekshiring.
#include
#include
using namespace std;
string Palindrom(string S)
{
string P = S;
reverse(P.begin(), P.end());
if (S == P) {
return "Polindrom";
}
else {
return "Polindrom emas";
}
}
int main()
{
string str, data;
cout << "Qanday fayl hosil qilinsin: ";
getline(cin, str);
cout << "\nSo`zni kiriting : ";
getline(cin, data);
cout << "Berilgan so`z : ";
cout << Palindrom(data);
str = str + ".txt";
ofstream fwriter(str.c_str());
fwriter << data << endl;
return 0;
}
4-Jadval
3 .String turidagi A satrda “gul” soʻzi koʻp, shu soʻzni A satrdan tozalovchi dastur tuzing.
#include
#include
using namespace std;
int main ()
{
string soz[100],a="gul",s;
getline(cin,s);
int n=s.find("gul");
while(n!=-1){
s.erase(n,3);
n=s.find("gul");
}
cout <
return 0;
}
Do'stlaringiz bilan baham: |