11 Temmuz 2014, 10:29
|
#1 |
Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
| Mükemmel Sayı
Kullanıcıdan alınan bir sayının mükemmel sayı olup olmadığını test eden programdır. Kod: Kodu kopyalamak için üzerine çift tıklayın! //---------------------------------------------------------------------------
#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 toplam=0;
int c=StrToInt(InputBox("Sayı Gir","SONUC",""));
for(int i=1;i<c;i++)
{
if(c%i==0)
toplam+=i;
}
if(c==toplam)
Application->MessageBox("Sayı Mükemmel Sayıdır","SONUÇ",MB_ICONINFORMATION) ;
else
Application->MessageBox("Sayı Mükemmel Sayı Değildir","SONUÇ",MB_ICONINFORMATION);
}
//--------------------------------------------------------------------------- |
| |