first
  
last
 
 
start
stop
No valid database connection You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND a.state = 1 ORDER BY a.created DESC' at line 1 SQL=SELECT a.id AS id, a.title AS title, a.created AS created, a.introtext AS intro, a.catid AS catid, a.sectionid AS sectionid, a.ordering AS ordering, b.title AS section, c.title AS cat, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END AS catslug FROM jos_content AS a LEFT JOIN jos_sections AS b ON b.id = a.sectionid LEFT JOIN jos_categories AS c ON c.id = a.catid WHERE ( ( LOWER(a.created_by_alias) LIKE '%ga=%' AND LOWER(a.created_by_alias) LIKE '%%' ) OR a.created_by = ) AND a.state = 1 ORDER BY a.created DESC
There are no translations available.

Ders 4: Örnekler - Examlpes

 

10. Örnek

#include<iostream>
#include<conio.h> //getch(); için
using namespace std;

main()
{

cout<<"Merhaba dunya\n" ;

getch(); //Ekranın hemen kapanmamasını sağlar

}

11. Örnek: Sayı Bulmaca

#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

void Start ();
void GetResults ();

int i, j, hayat, maksimum; //int tamsayı tanımlar
char c; //char karakter tanımlar

void
Start ()
{
i = 0;
j = 0;
hayat = 0;
maksimum = 6;

cout << "Zor modu sec:\n";
cout << "1 : Kolay (0-20)\n";
cout << "2 : Orta (0-40)\n";
cout << "3 : Zor (0-60)\n";
cout << "veya cikmak için farkli bir sey secin\n";
c = 30;

cin >> c; // kullanıcının seçimmini okur
cout << "\n";

switch (c) //Seçimime göre aşagıdaki şıkları işletir
{
case '1' : maksimum = 20; // Rastgele sayı 0 ile maksimum arasında olacaktır
break;
case '2' : maksimum = 40;
break;
case '3' : maksimum = 60;
break;
default : exit(0); //hiç biri değilse ekranı kapatır
break;
}

hayat = 6; // oyuncunun kaç seçim yapacağını belirler
srand( (unsigned)time( NULL ) ); // tamsayı rastgele sayı üreten fonksiyon
j = rand() % maksimum; // j 0 ile maximum sayı arasında bir sayıyı tutar

GetResults();

}

void
GetResults ()
{
if (hayat <= 0)
// şayet 6 seçim sonundada bilemezsiseniz
{
cout << "Kaybettiniz !\n\n";
Start();
}

cout << "Bir sayi: \n";
cin >> i; // oyuncunun sayısını okur

if ((i>maksimum) || (i<0)) // şayet oyuncunun sayısı doğru değilse tekrar başlatır.
{
cout << "Hata : Sayi 0 ile " << maksimum << " arasinda degil\n";
GetResults();
}

if (i == j)
{
cout << "Kazandiniz !\n\n"; // Oyuncu doğru sayıyı bulursa
Start();
}

else if (i>j)
{
cout << "Cok buyuk\n";
hayat = hayat - 1; // secenek sayınızı bir azaltır
cout << "Kalan sayi hayat: " << hayat << "\n\n";
GetResults();
}

else if (i<j)
{
cout << "Cok kucuk\n";
hayat = hayat - 1;
cout << "Kalan sayi hayat:\n" << hayat << "\n\n";
GetResults();
}
}

int
main ()
{
cout << "** Sayi bulmaca **\n";
cout << "Secilen bir sayiyi bulacaksiniz. \n";
cout << "5 tahmin hakkiniz var\n";
cout << "Sayi bulmaca size çok buyuk veya cok kucuk olarak bildirecek ve sizde tahmin edeceksiniz\n\n";
Start();
return 0;
}

 

MSc. Mehmet Keçeci

Login Form

Bilim Tarihi

Yüksek Enerji Fiziği