Satrning uzunligini va sozlar soni topilsin


Download 15.55 Kb.
Sana21.04.2023
Hajmi15.55 Kb.
#1373774
Bog'liq
boriev


  1. Satrning uzunligini va sozlar soni topilsin.

#include
using namespace std;
int main()
{
string S;
getline (cin,S);
int n=S.length(),son=1;
for (int i=0;iif (S[i]==' '&& S[i+1]!=' ')son++;
cout<<"uzunligi="<cout<<"soni="<return 0;
}


  1. Satrdagi sozni teslarisiga ogirish.

#include
using namespace std;
int main()
{
string S;
getline (cin,S);
int n=S.length(),son=1;
for (int i=n;i>-1;i--)
cout<return 0;
}


  1. Arifmetik ifodani f fayldan g faylga natijani chiqarin.

#include
#include
#include
using namespace std;
int main ()
{
ifstream F1("f.txt");
float X,S=0,P=1,S2=0,P2=1;
do
{
F1>>X;
S+=X;
P*=X;
}
while (!F1.eof());
S2=pow (S,2);
P2=pow(P,2)+fabs(S);
cout <<"yigindisi:"< cout <<"kopaytmasi:"<
cout <<"yigindi kvadrati:"< cout <<"kvad va yeg modul:"<
cout <<"fayl oxiri:"< ofstream F2("g.txt");
F2 <<"yigindisi:"< F2 <<"kopaytmasi:"<
F2 <<"yigindi kvadrati:"< F2 <<"kvad va yeg modul:"<
F2 <<"fayl oxiri:"< F1.close();
F2.close();
return 0;}

  1. Satrda eng qisqa sozning uzunligini toppish.

#include
#include
using namespace std;
int main(){
string S;
getline(cin,S);
int n=S.length();
string min=0,t;
int i;
t=strtok(x," ");
min=t;
while(t!=NULL){
if(strlent(t) min=t;}
cout< cout<<"Uning uzunligi"<

return 0;
system("pause");
}



  1. 1.txt fayldagi malumot 2.txt faylga kochirilsin.

#include
#include
using namespace std;
int main()
{
ifstream F1("1.txt");
ofstream F2("2.txt");
char ch;
while (F1>>ch)
{

cout< F2<
}
F1.close();
F2.close();
return 0;
}


  1. Leksik taxlil

#include
using namespace std;

struct lexema {



int id;
string Name;
char type;
} tab[50];

int Scaner(string S) {


int n = S.length(), nl=0;
for(int i=0; i if(S[i]>='0' && S[i]<='9') {
tab[nl].id = nl;
tab[nl].Name+=S[i];
tab[nl].type='C';
}
else if(S[i]=='+' || S[i]=='-' || S[i]=='*' || S[i]=='/') {
nl++;
tab[nl].id = nl;
tab[nl].Name=S[i];
tab[nl].type='O';
nl++;
}
else if(S[i]=='=') {
nl++;
tab[nl].id = nl;
tab[nl].Name=S[i];
tab[nl].type='Z';
nl++;
}
else {
cout<<"\a Vveden nepravilniy simvol\a"; exit(1);
}

}
return nl;
}
int main(){
string S("");
S="56+45*7-4=";
int kollex;
kollex = Scaner(S);
cout<<"Tablitsa kodov lexem\nN\tImya\tKod\n";
for(int i=0; i cout< }
system("pause");

return 0;
}

Download 15.55 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling