7. Matnli fayl berilgan. Matnli fayldagi barcha uchragan belgilarni, probel va tinish belgilariga ega bo’lgan (takrorlanishsiz) belgili fayl hosil qilinsin. Belgilar kodi bo’yicha kamayish tartibida joylashsin
#include
#include
#include
using namespace std;
int main() {
ifstream es;
es.open("input.txt");
if(!es.is_open()){
cout<<"Hatolik bor faylni ochshda";
return 0;
}
ofstream fayl;
fayl.open("output.txt");
if(!fayl.is_open()){
cout<<"Hatolik bor faylni ochshda";
return 0;
}
int b[231];
for(int i=231;i<0;++i)b[i]=0;
char c;
string ans = "";
while(es >> c){
if(b[int(c)]==0)ans += c;
b[c]++;
}
es.close();
fayl << ans;
fayl.close();
cout << "Topshriq bajarildi";
return 0;
}
#include
#include
#include
#include
using namespace std;
int main(){
vector vec;
double temp = 0;
ifstream file("s1.txt");
if(file){
while(!file.eof()){
file >> temp;
vec.push_back(temp);}
}
file.close();
file.open("s2.txt");
if(file){
while(!file.eof()){
file >> temp;
vec.push_back(temp);}
}
file.close();
sort(vec.begin(), vec.end());
ofstream res_file("s3.txt");
if(res_file){
for(int i=0; ires_file << vec[i] << "\n";
cout << vec[i] << "\n";}
}
res_file.close();
system("pause");
return(0);
}
Do'stlaringiz bilan baham: |