Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bilietai
- #include <fstream>
- using namespace std;
- const char CDfv[] = "Duomenys.txt";
- const char CRfv[] = "Rezultatai.txt";
- //funkcijos prototipas
- int Atbulas(int nr);
- int main() {
- int n, m; //bilieto numeriu pradzia ir pabaiga
- int kiek = 0; //keli laimingi bilietai
- ifstream fd(CDfv);
- fd >> n >> m;
- fd.close();
- for (int i = n; i <= m; i++)
- if (i == Atbulas(i))
- kiek++;
- ofstream fr(CRfv);
- fr << kiek;
- fr.close();
- return 0;
- }
- //funkcija: atbulai uzrasytas skaicius
- int Atbulas(int nr) {
- int atb = 0;
- int sk;
- while (nr > 0) {
- sk = nr % 10;
- atb = atb * 10 + sk;
- nr /= 10;
- }
- return atb;
- }
Advertisement
Add Comment
Please, Sign In to add comment