Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <math.h>
- #include <fstream>
- using namespace std;
- ifstream fin ("input.txt");
- ofstream fout ("output.txt");
- int n=0, k=0, z=0, d=0, h=0;
- int main() {
- fin >> n;
- h=n;
- k= log10(n)+1;
- int m[k], q[k];
- for (int l; l<k; l++){
- q[l]= h%10;
- h=h/10;
- }
- for (int l=k-1; l>=0; l--){
- m[l]= q[z];
- z++;
- }
- for (int l; l<k; l++){
- if(m[l]==6){
- m[l]=9;
- } else if (m[l]==9){
- m[l]= 6;
- } else if (m[l]== 3 || m[l]== 4 || m[l]== 7){
- fout<< n;
- return 0;
- }
- }
- if (q[0]==0 || m[0]==0){
- fout<< n;
- return 0;
- }
- for (int l; l<k; l++){
- d= d+ m[l]*pow(10, l);
- }
- if(d>n){
- fout<< n;
- } else {
- fout<< d;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement