Board logo

标题: 召唤PASCAL高手... [打印本页]

作者: qq2008444     时间: 2009-7-5 09:24    标题: 召唤PASCAL高手...

论坛有学过Pascal的高手么...
本人正在学习此语言
大家有啥子心得体会敬请贴出.
谢谢...
作者: 微点专家     时间: 2009-7-5 09:32
好像现在大学都不教这个了,只有参加奥赛的学生学
作者: 微点专家     时间: 2009-7-5 09:33
我对编程这一块是学得一塌糊涂,所以我已经放弃了
作者: qq2008444     时间: 2009-7-5 12:44
= =
突然发现这玩意挺好玩。。没事干还能算算数学难题
作者: 微点专家     时间: 2009-7-5 13:52
学会这个能过渡到Delphi的
作者: qq2008444     时间: 2009-7-5 15:34
C也差不多..
作者: 专业路过     时间: 2009-7-5 21:05
我会背三字经呀
作者: 微点专家     时间: 2009-7-5 22:58


  Quote:
Originally posted by 专业路过 at 2009-7-5 21:05:
我会背三字经呀

能背完么?:D
作者: qq2008444     时间: 2009-7-5 23:16
某动物饲养中心用X元专款购买小狗(每只A元)和小猫(每只B元)两种小动物。
要求专款专用,(至少猫狗各一),正好用完?请求出方案的总数。如没有请输出0.
Input
输入一行,只有三个整数.分别为X,A,B.
Output
输出只有一行(这意味着末尾有一个回车符号),包括1个整数。

我的代码运行会超时(Time>1000ms),哪位能帮忙改成单循环的。。
-----偶是分割线----------
program test;
var  X,A,B,c,d,e,f:longint;
begin
readln(X,A,B);
e:=0;f:=1;
for c:=1 to (X div A) do
For d:=1 to (X div B) do
begin
if (c*A+d*B)=X then e:=e+f;
end;
writeln(e);
end.
-----偶是分割线----------
作者: 微点专家     时间: 2009-7-5 23:28
没法帮你了,兄弟。我数学打小就是最差的
作者: qq2008444     时间: 2009-7-6 08:44
哈...算了..
只能自己想招了
作者: qq2008444     时间: 2009-7-6 08:47    标题: 谷歌万岁...

比啥子有病和百度好用多了
改单循环后代码如下
-----偶是分割线----------
program test;
Var x,a,b,k,i:integer;
begin
Read(x,a,b);
k:=0;
For i:=1 to (x div a) do
if (x -i*a)mod b=0 then if x-i*a>=b then inc(k);
Writeln(k);
end.
-----偶是分割线----------
作者: 微点专家     时间: 2009-7-6 09:21
其实也不一定,这几个搜索,都有自己的特色,有时候这个的结果让自己能满意,但是下一次又是另外一个让自己满意,我都轮换着使用的
作者: qq2008444     时间: 2009-7-6 10:21
= =我当时写的8引擎搜索工具真好用
作者: snhao     时间: 2009-7-6 11:02    标题: 人民币取法问题

有面值1元、2元、5元、10元的人民币,从中取出20张使其总值为80元,问有少种取法,并列出取法。
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  idea:integer;
  ione,itwo,ifive,iten:integer;
  s:string;
begin
  idea:=0;
  For ione:=0 To 80 Do
    For itwo:=0 To 40 Do
      For ifive:=0 To 16 Do
         For iten:=0 To 8 Do
            if (ione+itwo*2+ifive*5+iten*10=80) then
              begin
              s:=' 壹元张数:'+inttostr(ione)+' 贰元张数:'+inttostr(itwo)
              +' 伍元张数:'+inttostr(ifive)+' 拾元张数:'+inttostr(iten);
                if (ione+itwo+ifive+iten)=20 then
                begin
                  listbox1.Items.Add(s);
                  inc(idea);
                end;
              end;
  label1.Caption:='取法有'+inttostr(idea)+'方法,具体如下:';
end;

end.
作者: sidineyqiao     时间: 2009-7-6 11:45
看到楼主的帖子。偶绝望了!
作者: 微点专家     时间: 2009-7-6 11:58


  Quote:
Originally posted by sidineyqiao at 2009-7-6 11:45:
看到楼主的帖子。偶绝望了!

我比你先绝望:lol:
作者: qq2008444     时间: 2009-7-6 12:59


  Quote:
Originally posted by snhao at 2009-7-6 11:02:
有面值1元、2元、5元、10元的人民币,从中取出20张使其总值为80元,问有少种取法,并列出取法。
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Fo ...

我说。。。这是Pascal么 。。。这分明是Delphi。。。
这个题目和此题相似。。
---偶是分割线---
Description
用一张一元票换1分、2分和5分的硬币,每种至少一枚, 问有几种换法.
Input

Output
输出只有一行(这意味着末尾有一个回车符号),包括1个整数。
---偶是分割线---
Pascal代码
----偶是分割线----
program test;
var a,b,c,d:longint;
begin
d:=0;
for a:=1 to 93 do
  for b:=1 to 47 do
   for c:=1 to 19 do
if (a+2*b+5*c)=100 then d:=d+1;
writeln(d);
end.
----偶是分割线----




欢迎光临 微点交流论坛 (http://bbs.micropoint.com.cn/) bbs.micropoint.com.cn