-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
82 lines (69 loc) · 2.51 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// main.cpp
// algo 1.001
//
// Created by Can Babaoğlu on 4.10.2017.
// Copyright © 2017 Can Babaoğlu. All rights reserved.
//
#include "main.h"
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <chrono>
using namespace std;
using ms = chrono::microseconds;
using get_time = chrono::steady_clock ;
CardManager canbaba;
int main(int argc, const char * argv[]) {
long int size;
// cout<<"ne yazdım-> "<<argv[1]<<endl; TEST
if((canbaba.OpenTheFile(argv[3])==false)){/////////dosyayı aç, dosya adını terminalden al yolla.
cerr << "File can not be opened" << endl;
exit(1);
}
canbaba.ReadFromFile(canbaba.myvec);/////dosyadan vektöre oku.
size=canbaba.myvec.size();// vektör dolduktan sonra size ı alalım.
long int p = 0;
long int r = size-1;
//canbaba.PrintTheVector(canbaba.myvec); // doğru dolduruyor vektörü TEST
////////////////TERMİNALDEN GİRİLENLERE GÖRE UYGUN METHODU ÇAĞIR/////////////////////////
auto start = get_time::now(); //süreyi burda alıyorum bu küçük işlemler sortun yanında göz ardı edilebilir
if(strcmp((argv[1]),"-full")==0){
if(strcmp((argv[2]),"-i")==0){
canbaba.FullInsertionSort(canbaba.myvec, size);
}
else if(strcmp(argv[2],"-m")==0 ){
canbaba.FullMergeSort(canbaba.myvec, p, r);
}
else {
cout<<"please type the second argv properly ( -i or -m) "<<endl;
return 0;
}
}
else if(strcmp(argv[1],"-filter")==0 ){
if(strcmp((argv[2]),"-i")==0){
canbaba.FilterInsertionSort(canbaba.myvec, size);
}
else if(strcmp(argv[2],"-m")==0 ){
canbaba.FilterMergeSort(canbaba.myvec, p, r);
}
else {
cout<<"please type the second argv properly ( -i or -m) "<<endl;
return 0;
}
}
else {
cout<<"please type the first argv properly ( -full or -filter) "<<endl;
return 0;
}
auto end = get_time::now();
auto diff = end - start;
cout<<"Elapsed time is : "<< chrono::duration_cast<ms>(diff).count()<<" ms "<<endl; /// sortta işi bitirip gelince süreyi yaz
////////////////TERMİNALDEN GİRİLENLERE GÖRE UYGUN METHODU ÇAĞIR/////////////////////////
//cout<<"---Sort called---"<<endl; TEST
canbaba.WriteToFile(canbaba.myvec, size, argv[4]);
//canbaba.PrintTheVector(canbaba.myvec); // TEST
return 0;
}