IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   C ve C++ (https://www.ircforumlari.net/c-ve-c/)
-   -   Asal Test (https://www.ircforumlari.net/c-ve-c/600413-asal-test.html)

Swat 11 Temmuz 2014 10:25

Asal Test
 
Girilen sayının asal olup olmadığının testini yapar. Sonuçta uygun bir mesaj ile sizi bilgilendirir.

Kod:

//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
 
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int kontrol=0;
int c=StrToInt(InputBox("Sayıyı Girin","SONUC",""));
if(c==2)
Application->MessageBox("Girilen Sayı Asaldır","SONUC",MB_ICONINFORMATION);
else
{
for(int i=2;i<c;i++)
{
if(c%i==0)
{kontrol=1; break;}
}
if(kontrol==0)
Application->MessageBox("Girilen Sayı Asaldır","SONUC",MB_ICONINFORMATION);
else
Application->MessageBox("Girilen Sayı Asal Değildir","SONUC",MB_ICONINFORMATION);
}
}
//---------------------------------------------------------------------------



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 10:55.

Powered by vBulletin® Version 3.8.8 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2024 IRCForumlari.Net