Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int aSize;
- cout << "Enter number of elements: ";
- cin >> aSize;
- cout << endl;
- //Fill Array
- int a[aSize];
- srand(time(NULL));
- for(int i = 0; i < aSize; i++) {
- a[i] = (rand() % (10000 + 1) - 5000);
- }
- //Print Elements
- for(int i = 0; i < aSize; i++) {
- cout << a[i] << endl;
- if(i % 200 == 0 && i != 0) {
- bool keyPress = false;
- while(keyPress == false) {
- char key;
- cout << endl;
- cout << "Continue? [y]" << endl;
- cin >> key;
- if(key == 'y') {
- keyPress = true;
- }
- }
- }
- }
- cout << endl;
- //Process Array
- int *p = a, *pMax = p, *pMin = p, tot;
- for(p; p < (a + aSize); p++) {
- tot += *p;
- if(*p > *pMax) {
- pMax = p;
- }
- if(*p < *pMin) {
- pMin = p;
- }
- }
- cout << "Max number is: " << *pMax << endl;
- cout << "Min number is: " << *pMin << endl;
- cout << "Total is: " << tot << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement