Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari unvirsiteti telekommunikatsiyalar fakulteti
tarix 14.03.2023 ölçüsü 0,58 Mb. #87772
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNVIRSITETI
TELEKOMMUNIKATSIYALAR FAKULTETI
Dasturlash fani uchun
Bajardi:Egamberdiyev Laziz SWD011 guruh talabasi
Tekshirdi: Saidov Samandar
TOSHKENT – 2022
6-misol:
6
Berilgan nomdagi matnli faylni yaratish va unga satr kiritish dasturini tuzing. Boshlanishi va tugashi bir xil harfdan iborat so’zni ekranga chiqaring.
KODLARI:
#include
#include
using namespace std ;
int main(){
ofstream input("input.txt");
ifstream output("input.txt");
string str; getline(cin,str);
if(str[0]==str[str.length()-1]) input <
else {
cout <<"Error"<
exit(1);
}
output >>str;
cout <
input.close();
output.close();
return 0;
}
6
input faylida n va m natural sonlari berilgan. formulani hisoblab , output fayliga yozish dasturini tuzing.
Yechish:
#include
#include
using namespace std;
int n,m;
ifstream in("input.txt");
ofstream out("output.txt");
int main(){
float s=0,p=1;
in >> n >> m;
cout << n << " " << m << endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
p*=float(i+j)/(i*j);
}
cout << p << " ";
s+=p;
p=1;
}
out << s;
cout << endl << s;
} Dostları ilə paylaş: