
Поликарп
4 год назад
Задание по программированию.Желательно на с++. 25 поинтов

ОТВЕТЫ

McCoy Michael
Oct 24, 2020
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int main() {
ifstream fi;
ofstream fo;
fi.open("input.txt");
string sd,sw,inp = "";
int i,j;
while(!fi.eof())
{
fi>>i>>j;
if (((i%2==0) && (j%2==0)) || ((i%2==1) && (j%2==1)))
sd=sd+char(i+48)+" "+char(j+48)+" ";
else sw=sw+char(i+48)+" "+char(j+48)+" ";
}
fi.close();
fo.open("output.txt");
fo<<sw<<endl;
fo<<sd<<endl;
fo.close();
return 0;
}
#include <fstream>
#include <cstring>
using namespace std;
int main() {
ifstream fi;
ofstream fo;
fi.open("input.txt");
string sd,sw,inp = "";
int i,j;
while(!fi.eof())
{
fi>>i>>j;
if (((i%2==0) && (j%2==0)) || ((i%2==1) && (j%2==1)))
sd=sd+char(i+48)+" "+char(j+48)+" ";
else sw=sw+char(i+48)+" "+char(j+48)+" ";
}
fi.close();
fo.open("output.txt");
fo<<sw<<endl;
fo<<sd<<endl;
fo.close();
return 0;
}
701
Смежные вопросы: