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.
- Prepare
- C++
- Introduction
- Arrays Introduction
- Discussions
Arrays Introduction
Arrays Introduction
+ 0 comments My solution:
include
include
include
include
include
include
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int N; cin >> N ; int arr[N]; int inputs;for(int i = 0; i< N; i++){ cin >> arr[i]; } stack <int> s1; for(int i : arr){ s1.push(i); } while (!s1.empty()) { cout << s1.top() << " "; s1.pop(); } return 0;
}
+ 0 comments My solution:
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int size; cin >> size; int arr[size]; for (int i = 0; i < size; i++){ cin >> arr[i]; } for (int j = size-1; j >= 0; j--){ cout << arr[j] << " "; } return 0; }
+ 0 comments int main() { int n; scanf("%d", &n); int arr[n]; for (int i=0; i<n; ++i){ scanf("%d", &arr[i]); } for (int i=n-1; i>=0; --i){ printf("%d ", arr[i]); } return 0; }
+ 1 comment include
include
include
include
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n ; cin >> n; int *arr = new int[n]; for(int i = 0 ; i < n ; i++) { cin >> *(arr+i); } for (int i = n-1 ; i >=(n/2) ; i--){ int k = n-1-i; int temp = *(arr+k); *(arr+k) = *(arr+i); *(arr+i) = temp; } for(int i = 0 ; i < n ; i++) { cout << *(arr+i) << " "; }
}
+ 0 comments include
include
include
include
include
using namespace std;
int main() { vector v; int n; cin>>n; for(int i=0;i>x; v.push_back(x); } for(int i=n-1;i>=0;i--) { cout<
return 0;
}
Load more conversations
Sort 1262 Discussions, By:
Please Login in order to post a comment