Skip to content

Instantly share code, notes, and snippets.

@morontt
Created May 18, 2014 08:14
Show Gist options
  • Save morontt/def5f2a8ebf3d8a990ad to your computer and use it in GitHub Desktop.
Save morontt/def5f2a8ebf3d8a990ad to your computer and use it in GitHub Desktop.
salazar 1
#include <iostream>
#include <ctime>
#include <stdlib.h>
using namespace std;
int main() {
int s[10];
int z;
int count = 0;
char lett;
cout << "z = ";
cin >> z;
srand(time(NULL));
for (int i = 0; i < 10; i++) {
s[i] = 1 + rand() % 100;
}
cout << "array:" << endl;
for (int i = 0; i < 10; i++) {
cout << s[i] << ' ';
}
cout << endl << endl;
for (int i = 0; i < 10; i++) {
if (s[i] > z) {
s[i] = z;
count++;
}
}
cout << "modified array:" << endl;
for (int i = 0; i < 10; i++) {
cout << s[i] << ' ';
}
cout << endl << endl;
cout << "count: " << count << endl;
cout << endl << "Enter a letter to end the program" << endl;
cin >> lett;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment