Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int N;int mid=0; int area = 0;int perimeter=0;
  6. scanf("%d", &N);
  7. int a[N];
  8. for(int i = 0; i<N; i++)
  9. {
  10.  
  11.  
  12. scanf("%d", &a[i]);
  13.  
  14. area = area + (2*a[i]);
  15.  
  16. for(int j = 0; j<N; j++)
  17. {
  18. if(j = 0)
  19. {
  20. mid = mid + a[0];
  21. }
  22. if(j > 0)
  23. {
  24. mid = mid + a[j];
  25. mid = mid - a[j-1];
  26. }
  27. if(mid < 0)
  28. {
  29. mid*-1;
  30. }
  31. }
  32. perimeter = 2 * (a[1] + a[N] + 2*N + mid);
  33. }
  34.  
  35. area = area*2;
  36. perimeter = perimeter*2;
  37.  
  38. printf("%d ", perimeter);
  39. printf("%d", area);
  40.  
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement