Satrning uzunligini va sozlar soni topilsin
Download 15.55 Kb.
|
boriev
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;i cout<<"uzunligi="< } 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< } 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 <<"yigindi kvadrati:"< cout <<"fayl oxiri:"< F2 <<"yigindisi:"< F2 <<"yigindi kvadrati:"< F2 <<"fayl oxiri:"< F2.close(); return 0;} 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) cout< return 0; system("pause"); } 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< } F1.close(); F2.close(); return 0; } 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 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 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
ma'muriyatiga murojaat qiling