Open alisinancoban opened 7 years ago
Outlookhttp://aka.ms/weboutlook'tan gönderildi
Gönderen: Ali Sinan Çoban notifications@github.com Gönderildi: 25 Nisan 2017 Salı 15:02 Kime: serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda Bilgi: Subscribed Konu: [serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda] General performance improvements (#3)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda/issues/3, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKLuOMhv7q-uU_Zjbrb-CfLell5zlCTDks5rzeDEgaJpZM4NHYbc.
using namespace std;
class Sort { public: virtual void Compare(int dizi[], int elemanSayisi) = 0;
void getInput() { cout << "Enter 3 different number:" << endl; for (int i = 0; i < 3; i++) { cin >> tempArray[i]; } } void checkInput() { for (int i = 0; i < 3; i++) { if (tempArray[i] < 0 ) { cout << "Invalid input! (Negative number error.)" << endl; } } } void display() { for (int i = 0; i < 3; i++) { cout << "Number " << (i + 1) << " :" << tempArray[i] << endl; } } void sort() { getInput(); checkInput(); Compare(tempArray,3); display(); }
private:
int tempArray[3];
};
class AscendingSort : public Sort { public: void Compare(int dizi[], int elemanSayisi) override { int temp; int i, j;
for (i = 1; i<elemanSayisi; i++) { for (j = 0; j<elemanSayisi - i; j++) { if (dizi[j] > dizi[j + 1]) { temp = dizi[j]; dizi[j] = dizi[j + 1]; dizi[j + 1] = temp; } } } }
class DescendingSort : public Sort { void Compare(int dizi[], int elemanSayisi) override { int temp; int i, j;
for (i = 1; i<elemanSayisi; i++) { for (j = 0; j<elemanSayisi - 1; j++) { if ( dizi[j + 1] > dizi[j]) { temp = dizi[j]; dizi[j] = dizi[j + 1]; dizi[j + 1] = temp; } } } }
int main() { AscendingSort * myAscendingSort = new AscendingSort; myAscendingSort->sort();
DescendingSort *myDescendingSort = new DescendingSort; myDescendingSort->sort(); //stop int stop; cin >> stop; return 0;
}
Outlookhttp://aka.ms/weboutlook'tan gönderildi
Gönderen: Ali Sinan Çoban notifications@github.com Gönderildi: 25 Nisan 2017 Salı 15:02 Kime: serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda Bilgi: Subscribed Konu: [serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda] General performance improvements (#3)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/serhatuzunbayir/VENDINGMACHINE-2_AliSinan_Ataberk_Arda/issues/3, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKLuOMhv7q-uU_Zjbrb-CfLell5zlCTDks5rzeDEgaJpZM4NHYbc.
include
include
using namespace std;
class Sort { public: virtual void Compare(int dizi[], int elemanSayisi) = 0;
private:
};
class AscendingSort : public Sort { public: void Compare(int dizi[], int elemanSayisi) override { int temp; int i, j;
};
class DescendingSort : public Sort { void Compare(int dizi[], int elemanSayisi) override { int temp; int i, j;
};
int main() { AscendingSort * myAscendingSort = new AscendingSort; myAscendingSort->sort();
}