Arrays Introduction

Sort by

recency

|

1333 Discussions

|

  • + 0 comments

    Constraints

    1 <= N <= 1000

    1 <= A[i] <= 10000, where A[i] is the i'th integer in the array.

    Why is anyone not coding as per the constraints?

  • + 0 comments

    include

    using namespace std;

    int main() { int n; cin >> n; int arr[n];

    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    
    for (int j = n - 1; j >= 0; j--){
        cout << arr[j] << " ";
    }
    return 0;
    

    }

  • + 0 comments
      int arr[1000];
        int a ;
        cin >> a;
           for(int i = 0 ; i < a ; i++){
            int num;
            cin >> num;
            arr[i] = num;
           }
           
           for (int j = a ; j > 0; j--) {
           cout << arr[j-1] << " ";
           }
    
  • + 0 comments

    simple code

    int main() {

    int n;
    cin>>n;
    int arr[n];
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    for(int i=n-1 ; i>=0 ; i--){
        cout<<arr[i]<< " ";
    }   
    return 0;
    

    }

  • + 0 comments

    string reverse

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
       cin>>arr[i];  
    } 
    
    for(int j=n-1;j>=0;j--)
    {
        cout<<arr[j]<<" ";
    }
    
    return 0;
    

    }