Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("suma6.in");
- ofstream fout("suma6.out");
- int special(int a)
- {
- int aux=a,nr_cif=0;
- while(aux>9)
- {
- nr_cif++;
- aux/=10;
- }
- if(nr_cif%2==1)
- return 0;
- if(aux==a%10)
- return 1;
- return 0;
- }
- int cif_mij(int a)
- {
- int aux=a,nr_cif=0;
- while(aux)
- {
- nr_cif++;
- aux/=10;
- }
- for(int i=1; i<=nr_cif/2; i++)
- a/=10;
- return a%10;
- }
- int main()
- {
- int n,x,s=0;
- fin>>n;
- for(int i=1; i<=n; i++)
- {
- fin>>x;
- if(special(x))
- s+=cif_mij(x);
- }
- fout<<s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement