Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //massiv.h
- void Create(double *&mas, int n);
- void Fill(double *mas);
- void Show(double* mas);
- void Delete(double *&mas);
- void Sort(double *mas);
- void Swap(double &a, double &b);
- // massiv.cpp
- #include <malloc.h>
- #include <iostream>
- using namespace std;
- #include "massiv.h"
- void Create(double *&mas, int n){
- mas = new double[n];
- }
- void Fill(double *mas){
- if (!mas) return;
- int n = _msize(mas) / sizeof(*mas);
- cout << "Введите " << n << " элементов:" << endl;
- for (int i = 0; i < n; i++)
- {
- cout << "Элемент №" << i << ": ";
- cin >> mas[i];
- }
- }
- void Show(double *mas){
- int n = _msize(mas) / sizeof(*mas);
- for (int i = 0; i < n; i++)
- {
- cout << mas[i] << ((i==n-1)?"":" ");
- }
- cout << endl;
- }
- void Delete(double *&mas){
- if (mas)
- delete[] mas;
- mas = NULL;
- }
- void Swap(double &a, double &b){
- double t = a;
- a = b;
- b = t;
- }
- void Sort(double *mas){
- int n = _msize(mas) / sizeof(*mas);
- for (int i = 0; i < n - 1; i++){
- }
- }
- // main.cpp
- #include <iostream>
- using namespace std;
- #include "massiv.h"
- void main(){
- setlocale(LC_ALL, "Russian");
- double *x = NULL;
- int n;
- cout << "Введите размер массива: ";
- cin >> n;
- Create(x, n);
- Fill(x);
- cout << "Исходный массив: ";
- Show(x);
- Sort(x);
- cout << "Отсортированный массив: ";
- Show(x);
- Delete(x);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement