Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //problema 19
- #include <iostream>
- #include <fstream>
- using namespace std;
- int palindrom(int n){
- cout<<n<<" ";
- int c = n%10;
- while(n>9)
- n/=10;
- cout<<c<<" "<<n<<endl;
- if(c == n) return 1;
- else return 0;
- }
- int main(){
- ifstream in("matrice.in");
- ofstream out("matrice.out");
- int a[50][50], n, i, j, s=0;
- in>>n;
- for(i = 0;i<n;i++)
- for(j = 0;j<n;j++)
- in>>a[i][j];
- for(i = 0;i<n;i++)
- for(j = 0;j<n;j++){
- if(j==0 || i==0 || i==n-1 || j==n-1)
- if(palindrom(a[i][j]))
- out<<a[i][j]<<" ";
- if(i<j)
- s+=a[i][j];
- }
- out<<endl<<s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement