Laboratoriya mashg’ulotini bajarish bo’yicha variantlar
Download 239.52 Kb.
|
Laboratoriya mashg
#include "stdafx.h" #include #include #include #include #include using namespace std; int func(string line){ int i=1; string str; bool s=0,s1=0, s2=0; int e1=0,e2=0; int z2=0; e1=0; e2=0; string h=""; int h2=0; for(int t=0; t s=0; s1=0; s2=0; e1=0; e2=0; string d; d.assign(line,t,1);
if(d=="=" || d=="+" || d=="-" || d=="*" || d=="/" ){ if(line[t-1]=='+' || line[t-1]=='-' || line[t-1]=='*' || line[t-1]=='/' ){
if(d!="=" && (line[t-2]!='+' || line[t-2]!='-' || line[t-2]!='*' || line[t-2]!='/') ){ cout< e1=1;
}
if(line[t+1]=='+' || line[t+1]=='-' || line[t+1]=='*' || line[t+1]=='/' ){ cout< e1=1;
}
if(atof(h.c_str())){ a=atof(h.c_str()); cout<<"raqam("<
}
else if(e1!=1){ cout<<" operator("<
}
h2=0; h.clear(); else if(d==";" || d==","){ e2=t; s1=1; s=0; s2=0; if((d!=",") && line[t-1]=='+' || line[t-1]=='-' || line[t-1]=='*' || line[t-1]=='/' ){ if(d!="=" && (line[t-2]=='+' || line[t-2]=='-' || line[t-2]=='*' || line[t-2]=='/') ){ cout< e1=1;
}
if(line[t+1]=='+' || line[t+1]=='-' || line[t+1]=='*' || line[t+1]=='/' ){ cout< e1=1;
}
if(atof(h.c_str())){ a=atof(h.c_str()); cout<<"Raqam("< } else if(e1!=1){ cout<<"identifikator("< cout<<" Ajratuvchi("< } h2=0; h.clear(); } else if(d=="{" || d=="}"){ e2=t; s1=1; s=0; s2=0; if((d!=",") && line[t-1]=='+' || line[t-1]=='-' || line[t-1]=='*' || line[t-1]=='/' ){ if(d!="=" && (line[t-2]=='+' || line[t-2]=='-' || line[t-2]=='*' || line[t-2]=='/') ){ cout< e1=1;
}
if(line[t+1]=='+' || line[t+1]=='-' || line[t+1]=='*' || line[t+1]=='/' ){ cout< e1=1;
}
if(atof(h.c_str())){ a=atof(h.c_str()); cout<<"Raqam("< } else if(e1!=1){ cout<<"identifikator("< cout<<" Figurali qavs("< } h2=0; h.clear(); } else if(d==" "){ s2=1; s=0; s1=0; float a; if(atof(h.c_str())){ a=atof(h.c_str()); cout<<"Raqam("< } else if(!h.empty()) cout<<"identifikator("<
} else { h=h+d; h2++; } } if(s==0 && s1==0 && s2==0) { cout<<"identifikator("< } i++;
} int main(){ ifstream oqi("1.txt"); if(!oqi.is_open()){ cout<<"Fayl topilmadi"< }
string l; {
if(oqi.fail()) break; func(l);
} return 0; } Download 239.52 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling