Untitled
unknown
c_cpp
a year ago
794 B
4
Indexable
#include <iostream> #include <fstream> using namespace std; int shifr(int a, int d) { int shifr1 = 0; int b = 1; while (a != 0) { int c = a % 10; c = (c + d) % 10; shifr1 += c * b; b *= 10; a /= 10; } return shifr1; } int main() { ifstream input("foo.txt"); ofstream output("fooo.txt"); if (!input.is_open() || !output.is_open()) { cout << "ERROR" << endl; return 1; } int N, d; input >> N >> d; for (int i = 0; i < N; ++i) { int a; input >> a; int shifr1 = shifr(a, d); output << shifr1 << endl; } input.close(); output.close(); return 0; }
Editor is loading...
Leave a Comment