We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. C++
  3. Introduction
  4. Arrays Introduction
  5. Discussions

Arrays Introduction

  • Problem
  • Submissions
  • Leaderboard
  • Discussions

    You are viewing a single comment's thread. Return to all comments →

  • ness_eg 2 years ago+ 1 comment

    Why did you add '&& N' in 'while(cout<

    0|
    ParentPermalink
    • JChiquin 2 years ago+ 2 comments

      That's because only with cout the loop will never end, so I add other constraints, when N will be 0 the loop will end (N is like an inverse iterator).

      Sorry my english

      8|
      ParentPermalink
      • ness_eg 2 years ago+ 0 comments

        thank you ^^

        0|
        ParentPermalink
      • narutoitachi329 2 weeks ago+ 1 comment
        int main() {
          int n, i = 0;
          cin >> n;
          int a[n];
          for (; i < n; i++)
            cin >> a[i];
          for (; i >0; i--)
            cout << a[i- 1] <<" ";
          return 0;
        }
        
        -3|
        ParentPermalink
        • JChiquin 2 weeks ago+ 1 comment

          You shouldn't use arrays like that. In fact, a is initialized with the first value of n what is garbage, something like 39281233, because is initialized in compile time not execution time, for dinamic size you must use pointers and the keyword new or vector from std.

          -1|
          ParentPermalink
          • narutoitachi329 2 weeks ago+ 0 comments
            [deleted]
            0|
            ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature