Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Паскаль, Turbo Pascal, PascalABC.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 25.10.2014, 18:27   #11
newerow1989
Я самый любопытный
Участник клуба
 
Аватар для newerow1989
 
Регистрация: 24.07.2012
Сообщений: 1,949
По умолчанию

Только в case не хватает слова end;!
С запрограммированным приветом, Неверов Евгений!
Сайт: http://newerow1989.ru
[Паскаль] [Delphi]
newerow1989 вне форума Ответить с цитированием
Старый 25.10.2014, 18:28   #12
Fly090
Пользователь
 
Аватар для Fly090
 
Регистрация: 25.09.2014
Сообщений: 24
По умолчанию

Цитата:
Цитата:
1:writeln('введите знак');
case x of
'/':
begin
if b=0 then goto 1;
Это работает? О_о
Всмысле оно нормально работает?
всё, исправил

Последний раз редактировалось Fly090; 25.10.2014 в 18:46.
Fly090 вне форума Ответить с цитированием
Старый 25.10.2014, 18:35   #13
newerow1989
Я самый любопытный
Участник клуба
 
Аватар для newerow1989
 
Регистрация: 24.07.2012
Сообщений: 1,949
По умолчанию

Ой, давайте завтра продолжим тему, а то мне уже спать пора. Поздно стало. Да еще этой ночью вставать и стрелки часов переводить!
С запрограммированным приветом, Неверов Евгений!
Сайт: http://newerow1989.ru
[Паскаль] [Delphi]
newerow1989 вне форума Ответить с цитированием
Старый 25.10.2014, 18:49   #14
min@y™
Цифровой кот
Старожил
 
Аватар для min@y™
 
Регистрация: 29.08.2014
Сообщений: 7,629
По умолчанию

Делаешь успехи.
Следующий этап - визуальное программирование под Windows. Задание №1: написать программу, чтоб не отличить от этого:
Изображения
Тип файла: png 6.png (13.4 Кб, 97 просмотров)
Расскажу я вам, дружочки, как выращивать грибочки: нужно в поле утром рано сдвинуть два куска урана...
min@y™ вне форума Ответить с цитированием
Старый 26.10.2014, 06:23   #15
newerow1989
Я самый любопытный
Участник клуба
 
Аватар для newerow1989
 
Регистрация: 24.07.2012
Сообщений: 1,949
По умолчанию

У меня готовая есть:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Label25Click(Sender: TObject);
    procedure Label4Click(Sender: TObject);
    procedure Label8Click(Sender: TObject);
    procedure Label11Click(Sender: TObject);
    procedure Label3Click(Sender: TObject);
    procedure Label7Click(Sender: TObject);
    procedure Label10Click(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure Label6Click(Sender: TObject);
    procedure Label9Click(Sender: TObject);
    procedure Label5Click(Sender: TObject);
    procedure Label12Click(Sender: TObject);
    procedure Label16Click(Sender: TObject);
    procedure Label15Click(Sender: TObject);
    procedure Label14Click(Sender: TObject);
    procedure Label13Click(Sender: TObject);
    procedure Label20Click(Sender: TObject);
    procedure Label17Click(Sender: TObject);
    procedure Label18Click(Sender: TObject);
    procedure Label19Click(Sender: TObject);
    procedure Label21Click(Sender: TObject);
    procedure Label22Click(Sender: TObject);
    procedure Label23Click(Sender: TObject);
    procedure Label24Click(Sender: TObject);
    procedure Label26Click(Sender: TObject);
    procedure Label27Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  a,b,c:real;
  znak:string;
  steret:boolean;

implementation

{$R *.dfm}

procedure test;
var i,pos_zapjataja:integer;
    s:string;
begin
   s:=Form1.Label1.Caption;
   If steret then
      s:=Copy(s,Length(s),1);
   steret:=false;
   Repeat
      If Copy(s,1,1)='0' then
         Delete(s,1,1);
   Until Copy(s,1,1)<>'0';
   If s='' then
      s:='0';
   pos_zapjataja:=Pos(',',s);
   If pos_zapjataja=1 then
      Insert('0',s,1);
   For i:=pos_zapjataja+1 to Length(s) do
      If Copy(s,i,1)=',' then
         Delete(s,i,1);
   Form1.Label1.Caption:=s;
   b:=StrToFloat(s);
   c:=b;
end;

function Logarifm(chislo, osnowanie: real): real;
begin
   Result:=0;
   If chislo=0 then
      Exit;
   chislo:=ln(chislo);
   If (osnowanie=0) or (osnowanie=1) then
      Exit;
   osnowanie:=ln(osnowanie);
   Result:=chislo/osnowanie;
end;

function wozwedenie_w_stepen(chislo, stepen: real): real;
begin
   If chislo=0 then
   begin
      MessageBox(0,'Число 0 в любой степени не существует','Возведение в степень',0);
      Result:=0;
      Exit;
   end;
   Result:=exp(stepen*ln(chislo));
end;

function Sinus(chislo: real): real;
begin
   Result:=sin(chislo*pi/180);
end;

function Cosinus(chislo: real): real;
begin
   Result:=cos(chislo*pi/180);
end;

function Tangens(chislo: real): real;
begin
   If cos(chislo*pi/180)=0 then
   begin
      Result:=1E999;
      Exit;
   end;
   Result:=sin(chislo*pi/180)/cos(chislo*pi/180);;
end;

function Cotangens(chislo: real): real;
begin
   If sin(chislo*pi/180)=0 then
   begin
      Result:=1E999;
      Exit;
   end;
   Result:=cos(chislo*pi/180)/sin(chislo*pi/180);;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Label1.Caption:='0';
   znak:='';
   a:=0;
   b:=0;
   c:=0;
end;

procedure TForm1.Label25Click(Sender: TObject);
begin
   Close;
end;

procedure TForm1.Label4Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'1';
   test;
end;

procedure TForm1.Label8Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'2';
   test;
end;

procedure TForm1.Label11Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'3';
   test;
end;

procedure TForm1.Label3Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'4';
   test;
end;

procedure TForm1.Label7Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'5';
   test;
end;

procedure TForm1.Label10Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'6';
   test;
end;
С запрограммированным приветом, Неверов Евгений!
Сайт: http://newerow1989.ru
[Паскаль] [Delphi]
newerow1989 вне форума Ответить с цитированием
Старый 26.10.2014, 06:26   #16
newerow1989
Я самый любопытный
Участник клуба
 
Аватар для newerow1989
 
Регистрация: 24.07.2012
Сообщений: 1,949
По умолчанию

Оказывается тут ограничения есть (до 5000 символов писать). Высылаю часть №2:
Код:
procedure TForm1.Label2Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'7';
   test;
end;

procedure TForm1.Label6Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'8';
   test;
end;

procedure TForm1.Label9Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'9';
   test;
end;

procedure TForm1.Label5Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+'0';
   test;
end;

procedure TForm1.Label12Click(Sender: TObject);
begin
   Label1.Caption:=Label1.Caption+',';
   test;
end;

procedure TForm1.Label26Click(Sender: TObject);
begin
   Label1.Caption:=Copy(Label1.Caption,1,Length(Label1.Caption)-1);
   test;
end;

procedure TForm1.Label16Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='+';
   steret:=true;
end;

procedure TForm1.Label15Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='-';
   steret:=true;
end;

procedure TForm1.Label14Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='*';
   steret:=true;
end;

procedure TForm1.Label13Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='/';
   steret:=true;
end;

procedure TForm1.Label18Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='x^y';
   steret:=true;
end;

procedure TForm1.Label19Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   b:=a;
   znak:='ln';
   steret:=true;
end;

procedure TForm1.Label20Click(Sender: TObject);
begin
   If znak='+' then
      c:=a+b;
   If znak='-' then
      c:=a-b;
   If znak='*' then
      c:=a*b;
   If znak='/' then
      If b=0 then
      begin
         Label1.Caption:='Деление на ноль!';
         Exit;
      end else
         c:=a/b;
   If znak='x^y' then
      c:=wozwedenie_w_stepen(a,b);
   If znak='ln' then
      c:=logarifm(a,b);
   a:=c;
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label17Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   c:=sqrt(a);
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label21Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   c:=sinus(a);
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label22Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   c:=cosinus(a);
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label23Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   c:=tangens(a);
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label24Click(Sender: TObject);
begin
   a:=StrToFloat(Label1.Caption);
   c:=cotangens(a);
   Label1.Caption:=FloatToStr(c);
end;

procedure TForm1.Label27Click(Sender: TObject);
begin
   FormCreate(nil);
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   If Key=96 then
      Label5Click(nil);
   If Key=97 then
      Label4Click(nil);
   If Key=98 then
      Label8Click(nil);
   If Key=99 then
      Label11Click(nil);
   If Key=100 then
      Label3Click(nil);
   If Key=101 then
      Label7Click(nil);
   If Key=102 then
      Label10Click(nil);
   If Key=103 then
      Label2Click(nil);
   If Key=104 then
      Label6Click(nil);
   If Key=105 then
      Label9Click(nil);
   If Key=110 then
      Label12Click(nil);
   If Key=107 then
      Label16Click(nil);
   If Key=109 then
      Label15Click(nil);
   If Key=106 then
      Label14Click(nil);
   If Key=111 then
      Label13Click(nil);
   If Key=13 then
      Label20Click(nil);
   If Key=89 then
      Label18Click(nil);
   If Key=78 then
      Label19Click(nil);
   If Key=83 then
      Label21Click(nil);
   If Key=79 then
      Label22Click(nil);
   If Key=84 then
      Label23Click(nil);
   If Key=71 then
      Label24Click(nil);
   If Key=8 then
      Label26Click(nil);
   If Key=27 then
      Label27Click(nil);
   If (Key=50) and (Shift=[ssShift]) then
      Label17Click(nil);
end;

end.
С запрограммированным приветом, Неверов Евгений!
Сайт: http://newerow1989.ru
[Паскаль] [Delphi]
newerow1989 вне форума Ответить с цитированием
Старый 26.10.2014, 10:40   #17
Stilet
Белик Виталий :)
Старожил
 
Аватар для Stilet
 
Регистрация: 23.07.2007
Сообщений: 57,097
По умолчанию

Жутковатый код... Без обид.
I'm learning to live...
Stilet вне форума Ответить с цитированием
Старый 26.10.2014, 22:45   #18
Fly090
Пользователь
 
Аватар для Fly090
 
Регистрация: 25.09.2014
Сообщений: 24
По умолчанию

newerow1989, сам писал?
Fly090 вне форума Ответить с цитированием
Старый 28.10.2014, 17:32   #19
Скрепостер
Заблокирован
 
Регистрация: 28.10.2014
Сообщений: 2
По умолчанию Калькулятор считающий без ограниченей цыфры

Код:
// OUNT.cpp: implementation of the COUNT class.
//
//////////////////////////////////////////////////////////////////////
  #include <iostream>
#include <string> // for strings
using namespace std;

class BigInt
{
public:
    BigInt(); // default constructor, value = 0
    BigInt(int); // assign an integer value
    BigInt(const string &); // assign a string
    // may need these in alternative implementation
    // BigInt(const BigInt &); // copy constructor
    // ~BigInt(); // destructor
    // const BigInt & operator = (const BigInt &);
    // assignment operator
    // operators: arithmetic, relational
    const BigInt & operator += (const BigInt &);
    const BigInt & operator -= (const BigInt &);
    const BigInt & operator *= (const BigInt &);
    const BigInt & operator /= (int num);
    string ToString() const; // convert to string
    int ToInt() const; // convert to int
    double ToDouble() const; // convert to double
    // facilitate operators ==, <, << without friends
    bool Equal(const BigInt & rhs) const;
    bool LessThan(const BigInt & rhs) const;
    void Print(ostream & os) const;
private:
    // other helper functions
    bool IsNegative() const; // return true iff number is negative
    bool IsPositive() const; // return true iff number is positive
    int NumDigits() const; // return # digits in number
    int GetDigit(int k) const;
    void AddSigDigit(int value);
    void ChangeDigit(int k, int value);
    void Normalize();
    // private state/instance variables
    enum Sign{positive,negative};
    Sign mySign; // is number positive or negative

    int myNumDigits; // stores # of digits of number
};

// free functions
ostream & operator <<(ostream &, const BigInt &);
istream & operator >>(istream &, BigInt &);
BigInt operator +(const BigInt & lhs, const BigInt & rhs);
BigInt operator -(const BigInt & lhs, const BigInt & rhs);
BigInt operator *(const BigInt & lhs, const BigInt & rhs);
BigInt operator *(const BigInt & lhs, int num);
BigInt operator /(const BigInt & lhs, int num);
BigInt operator *(int num, const BigInt & rhs);
bool operator == (const BigInt & lhs, const BigInt & rhs);
bool operator < (const BigInt & lhs, const BigInt & rhs);
bool operator != (const BigInt & lhs, const BigInt & rhs);
bool operator > (const BigInt & lhs, const BigInt & rhs);
bool operator >= (const BigInt & lhs, const BigInt & rhs);
bool operator <= (const BigInt & lhs, const BigInt & rhs);

#include <iostream>

using namespace std;

string add (string &s1, string &s2){
    int carry=0,sum,i;

    string  min=s1,
    max=s2,
    result = "";

    if (s1.length()>s2.length()){
        max = s1;
        min = s2;
    } else {
        max = s2;
        min = s1;
    }

    for (i = min.length()-1; i>=0; i--){
        sum = min[i] + max[i + max.length() - min.length()] + carry - 2*'0';
      
        carry = sum/10;
        sum %=10;



        result = (char)(sum + '0') + result;
    }

    i = max.length() - min.length()-1;

    while (i>=0){
        sum = max[i] + carry - '0';
        carry = sum/10;
        sum%=10;

        result = (char)(sum + '0') + result;
        i--;
    }

    if (carry!=0){
        result = (char)(carry + '0') + result;
    }       

    return result;
}

int main (){
    string a,b;

  


    cin >> a >> b;
     

    cout << add (a,b)<<endl; 
   

   



system("pause");
    return 0;
}
Скрепостер вне форума Ответить с цитированием
Старый 29.10.2014, 08:15   #20
Serge_Bliznykov
Старожил
 
Регистрация: 09.01.2008
Сообщений: 26,229
По умолчанию

Скрепостер, ничего что тема находится в разделе Паскаль и в названии темы присутствует указание языка: "Какую программу написать? (Паскаль) "?!!
Вас это никоим образом не смущает, как я понимаю?..
Serge_Bliznykov вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Написать программу для Паскаль 9 класс: составить программу которая печатает таблицу умножения и сложения натуральных чисел goodula Помощь студентам 0 23.01.2014 17:39
Какую программу написать на Delphi? Tadochi Помощь студентам 12 14.12.2013 23:21
Написать программу которая поможет определить в какой подъезд, на какой этаж, и в какую квартиру нужно идти почтальону qpuTuJlb Помощь студентам 7 25.04.2012 22:29
Какую программу можно написать на делфи чтобы она пользовалась большим спросом Xander Свободное общение 8 03.07.2008 16:11