Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int a[100][100],b[100][100];
- int niza[30];
- int n,i,j,s=0;
- scanf("%d",&n);
- for(i=0; i<n; i++) {
- for(j=0; j<n; j++) {
- scanf("%d",&a[i][j]);
- int p=1,k=0;
- while(p!=a[i][j]) {
- if(a[i][j]%p==0)
- k+=p;
- p++;
- }
- if(k==a[i][j]) {
- niza[s]=a[i][j];
- s++;
- }
- }
- }
- for(i=0; i<s; i++) {
- for(j=0; j<s-1; j++) {
- if(niza[j]>niza[j+1]) {
- int temp=niza[j];
- niza[j]=niza[j+1];
- niza[j+1]=temp;
- }
- }
- }
- if(s==0) {
- for(i=0; i<n; i++) {
- for(j=0; j<n; j++) {
- printf("0 ");
- }
- printf("\n");
- }
- printf("0");
- } else {
- for(i=0; i<n; i++) {
- for(j=0; j<n; j++) {
- if(i==j || i+j==n-1)
- printf("%d ",niza[s-1]);
- else
- printf("%d ",niza[0]);
- }
- printf("\n");
- }
- printf("%d",niza[s-1]-niza[0]);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment