MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
TELEKOMMUNIKATSIYALAR FAKULTETI
Dasturlash I fani
6-amaliy topshiriq
Bajardi: 413-22-guruh 1-bosqich talabasi
Sunnatullayev Abdulaziz
Tekshirdi: Ishniyazov Odil
TOSHKENT 2022
Variant -18
1-savol. Berilgan nomdagi matnli faylni yaratish va unga belgilar to’plamidan iborat satr kiritish dasturini tuzing. Faqat lotin harflar miqdorini aniqlang. Va lotin harflarni ekranga chiqaring.
Kodi:
#include
#include
using namespace std;
int main(){
ifstream in("input(3).txt");
ofstream out("output.txt");
string satr = "bhd12sd';,sgas.*/-dfsv+bc";
int c=0; string satr2 = "";
in >> satr;
for(int i=0; iif((int)satr.at(i)>=65 && (int)satr.at(i)<=90 || (int)satr.at(i)>=97 && (int)satr.at(i)<=122){
c++;
satr2+=satr.at(i);
}
}
out<out<cout<<"Bajarildi."<cout<in.close();
out.close();
}
Natijasi:
2-savol. input.txt faylida natural n soni berilgan. Berilgan n sonining raqamlarini teskari tartibda yozishdan hosil bo’lgan sonni output fayliga yozish dasturini tuzing.
Kodi:
#include
#include
using namespace std;
int main(){
ifstream in("input.txt");
ofstream out("output.txt");
int n,b=0;
in >> n;
while(n>0){
b = b*10+n%10;
n=n/10;
}
out << b;
cout<<"Bajarildi.";
in.close();
out.close();
}
Natijasi:
Do'stlaringiz bilan baham: |