Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- bool doctep(int a[100], int &n) {
- ifstream Doc("output.txt");
- if(Doc.fail()) {
- return false;
- }
- Doc >> n;
- for(int i = 0; i < n; i++) {
- Doc >> a[i];
- }
- return true;
- }
- int sapxeptang(int a[100], int n) {
- for(int i = 0; i < n-1; i++) {
- for(int j = i+1; j < n ; j++) {
- if( a[i] > a[j]) {
- int tmp = a[i];
- a[i] = a[j];
- a[j] = tmp;
- }
- }
- }
- return 0;
- }
- int ghi( int a[100], int n) {
- ofstream ghi("sapxeptang.txt");
- ghi << "sap xep tang dan la: ";
- for(int i = 0 ; i < n; i++) {
- ghi << a[i] << " ";
- }
- return 0;
- }
- int main() {
- int a[100];
- int n;
- if(doctep(a,n)) {
- sapxeptang(a,n);
- ghi(a,n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement