Скачиваний:
0
Добавлен:
30.05.2020
Размер:
1.78 Кб
Скачать
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include<math.h>
#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 figure=0,sum=0,i,a,b,st,k;
  double n=10;
  k=StrToInt(Edit1->Text);
  for (i=0;i<k;i++)
  {
   a=b=i;
   while(a)
   { a/=10;figure++; }
   st = pow(n,figure-1);
    while(b)
    {
     sum += pow((double)(b/st),figure);
     b%=st; st/=10; }
  if(sum==i)
     Memo1->Lines->Add("Armstrong -->"+IntToStr(i));
     figure=0;
     sum=0;
  }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Memo1KeyPress(TObject *Sender, char &Key)
{
 Key=0;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
 if((Key>='0') && (Key<='9')) {}
 else if(Key==8) {}
 else Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
 Memo1->Clear();
 Edit1->Clear();        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
 Memo1->Clear();
}
//---------------------------------------------------------------------------
Соседние файлы в папке A
  • #
    30.05.20203.79 Кб0Project1.bpr
  • #
    30.05.20201.07 Кб0Project1.cpp
  • #
    30.05.2020422.97 Кб0Project1.obj
  • #
    30.05.2020876 б0Project1.res
  • #
    30.05.2020655.36 Кб0Project1.tds
  • #
    30.05.20201.78 Кб0Unit1.cpp
  • #
    30.05.202051 б0Unit1.ddp
  • #
    30.05.20201.92 Кб0Unit1.dfm
  • #
    30.05.20201.18 Кб0Unit1.h
  • #
    30.05.2020464.15 Кб0Unit1.obj
  • #
    30.05.20201.78 Кб0Unit1.~cpp