#include <iostream>
#include <iomanip>
#include <conio.h>
#include <string>
#include <cstdlib>
#include <ctime>
#include <locale>
using namespace std;
int main()
{
int random, loopcounter = 0; //random seçim için random ve 3 kere giriş için loopcounter tanımladık.
string ch1, ch2, ch3;//seçilen stringler
string s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;//girilen stringler
srand(time(NULL));//gerçekten rastgele sayı üretmek için gereken kod
setlocale(LC_ALL, "Turkish");//konsol ekranında türkçe harflerin yazılabilmesi için
while (loopcounter < 3) {//loopcounter sıfırdan başladı: 0 1 2 olmak üzere üç kez çalışıcak
cout << "1. stringi giriniz : ";
getline(cin, s1);// (cin >> s1) şeklinde okuma yapmak isterseniz cin.ignore() komutunu hemen ardından yazın
cout << "2. stringi giriniz : ";
getline(cin, s2);
cout << "3. stringi giriniz : ";
getline(cin, s3);
cout << "4. stringi giriniz : ";
getline(cin, s4);
cout << "5. stringi giriniz : ";
getline(cin, s5);
cout << "6. stringi giriniz : ";
getline(cin, s6);
cout << "7. stringi giriniz : ";
getline(cin, s7);
cout << "8. stringi giriniz : ";
getline(cin, s8);
cout << "9. stringi giriniz : ";
getline(cin, s9);
cout << "10. stringi giriniz : ";
getline(cin, s10);
random = rand() % 10 + 1; //rastgele sayı üretiliyor 1 ile 10 arasında (+1 olmazsa 0 da dahil olur)
cout << "\r\nRandom = " << random << endl;//alogoritma kontrolü için istenirse silinebilir
if (loopcounter == 0)//ilk kez çalışma
{
if (random == 1)
ch1 = s1;
if (random == 2)
ch1 = s2;
if (random == 3)
ch1 = s3;
if (random == 4)
ch1 = s4;
if (random == 5)
ch1 = s5;
if (random == 6)
ch1 = s6;
if (random == 7)
ch1 = s7;
if (random == 8)
ch1 = s8;
if (random == 9)
ch1 = s9;
if (random == 10)
ch1 = s10;
}
if (loopcounter == 1)
{
if (random == 1)
ch2 = s1;
if (random == 2)
ch2 = s2;
if (random == 3)
ch2 = s3;
if (random == 4)
ch2 = s4;
if (random == 5)
ch2 = s5;
if (random == 6)
ch2 = s6;
if (random == 7)
ch2 = s7;
if (random == 8)
ch2 = s8;
if (random == 9)
ch2 = s9;
if (random == 10)
ch2 = s10;
}
if (loopcounter == 2)
{
if (random == 1)
ch3 = s1;
if (random == 2)
ch3 = s2;
if (random == 3)
ch3 = s3;
if (random == 4)
ch3 = s4;
if (random == 5)
ch3 = s5;
if (random == 6)
ch3 = s6;
if (random == 7)
ch3 = s7;
if (random == 8)
ch3 = s8;
if (random == 9)
ch3 = s9;
if (random == 10)
ch3 = s10;
}
loopcounter++;
}
cout << "\r\n1.Seçilen String = " << ch1;
cout << "\r\n2.Seçilen String = " << ch2;
cout << "\r\n3.Seçilen String = " << ch3;
system("pause");
return 0;
}