Last active
August 29, 2015 14:01
-
-
Save morontt/ffb95af61f6541a2d3b6 to your computer and use it in GitHub Desktop.
salazar 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main() { | |
int s[10]; | |
int z; | |
int count = 0; | |
ifstream in_stream; | |
ofstream out_stream; | |
char lett; | |
cout << "z = "; | |
cin >> z; | |
in_stream.open("input.txt"); | |
for (int i = 0; i < 10; i++) { | |
in_stream >> s[i]; | |
} | |
in_stream.close(); | |
out_stream.open("output.txt"); | |
cout << endl; | |
cout << "array:" << endl; | |
out_stream << "array:\n"; | |
for (int i = 0; i < 10; i++) { | |
cout << s[i] << ' '; | |
out_stream << s[i] << " "; | |
} | |
cout << endl << endl; | |
out_stream << "\n"; | |
for (int i = 0; i < 10; i++) { | |
if (s[i] > z) { | |
s[i] = z; | |
count++; | |
} | |
} | |
cout << "modified array:" << endl; | |
out_stream << "modified array:\n"; | |
for (int i = 0; i < 10; i++) { | |
cout << s[i] << ' '; | |
out_stream << s[i] << ' '; | |
} | |
cout << endl << endl; | |
out_stream << "\n"; | |
cout << "count: " << count << endl; | |
out_stream << "count: " << count << "\n"; | |
out_stream.close(); | |
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