Array Reversal | HackerRank - Samsus Salehin Sabbir

Header Ads

Array Reversal | HackerRank


Problem Link : Array Reversal

Solution :
      Develop by
 Samsus Salehin Sabbir 




  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>

  5. int main() {

  6.     /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
  7.     int n,i,*array;
  8.     scanf("%d",&n);
  9.     array = (int*) malloc(n *sizeof(int));
  10.     for(i=0;i<n;i++)
  11.     {
  12.         scanf("%d",array + i);
  13.     }
  14.     for(i=n-1;i>=0;i--)
  15.     {
  16.         printf("%d ",*(array+i));
  17.     }
  18.     printf("\n");
  19.     
  20.     
  21.     return 0;
  22. }

No comments

Powered by Blogger.