Satrlar bn ishlash 1



Download 0.85 Mb.
bet1/9
Sana26.12.2019
Hajmi0.85 Mb.
  1   2   3   4   5   6   7   8   9
Satrlar bn ishlash

1.1#include

#include

using namespace std;

int main(){

string n;

bool a=true;

int b=0;

getline(cin,n);

while(a){

b=n.find("mast");

if(b==-1) break;

else n.erase(b,4);



}

cout<


}



1.2

#include

#include

using namespace std;



int main() {

string satr;

int i,k,j;

getline(cin,satr);

string soz[6] ={"puton","output","out","input","one","in"};

for(int i=0;i<6;i++) {

if(satr.find(soz[i])

{

k=satr.find(soz[i]);



j=soz[i].length();

satr.erase(k,j);

}

}

if(satr.length()==0)



cout<<"Yes";

else cout<<"No"; }





Fayllar bilan ishalsh.

K butun soni va matnli fayl berilgan. Undagi K-nomerdagi satr o`chirilsin. Agar faylda bunday nomerdagi satr mavjud bo`lmasa, u holda fayl o`zgartirishsiz qoldirilsin.



Dastur kodi:

#include

#include

using namespace std;

int main()

{

int K;



cout<<"K = "; cin>>K; cin.ignore();

string fayl;

cout<<"Fayl nomini kiriting: ";

getline(cin, fayl);

ifstream read(fayl.c_str());

string satr[1000];

int n=0;

while(!read.eof())

{

getline(read, satr[n++]);



}

read.close();

ofstream write(fayl.c_str());

for(int i=0; i

if(i!=K-1) write<

write.close();

return 0;

}

Natija:







Do'stlaringiz bilan baham:
  1   2   3   4   5   6   7   8   9


Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2019
ma'muriyatiga murojaat qiling

    Bosh sahifa