Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- using namespace std;
- int cate(int x) {
- int c = 0;
- while (x && ++c)x/=10;
- return c;
- }
- int UltimeleCifre(int x, int n) {
- return x%(int)(pow(10, n)+0.1);
- }
- int main() {
- fstream citire("bac.txt", ios::in);
- int anterior = -1;
- for(int x,y,citire>>x,int lx=cate(x);citire>>y;x == UltimeleCifre(y, lx)? anterior = y : 1){}
- anterior+1?cout<<anterior<<endl:cout<<"Nu exista."<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement