Pascal之工种问题

 1 program Project2;
 2 Type
 3   ma=(A,B,C);
 4   wk=1..3;
 5   const
 6   x:array[ma,wk] of integer
 7     =((4,3,3),(2,4,3),(4,5,2));
 8 var
 9   maxefficiency:array[wk] of wk;
10   i,j,k:wk;
11   s:integer;
12   m:integer;
13
14 {$APPTYPE CONSOLE}
15 begin
16   { TODO -oUser -cConsole Main : Insert code here }
17   m:=0;
18   for i:=1 to 3 do
19    for j:=1 to 3 do
20    if i<>j then
21     begin
22     k:=6-i-j;
23     s:=x[A,i]+x[B,j]+x[C,k];
24      if s>m then
25       begin
26       m:=s;
27       maxefficiency[1]:=i;
28       maxefficiency[2]:=j;
29       maxefficiency[3]:=k;
30       end;
31       end;
32       for i:=1 to 3 do
33       writeln(‘工人‘:6,chr(64+i),‘工种‘:6,maxefficiency[i]);
34       writeln(‘最大效益‘ :12,m:4);
35       readln;
36       end.

时间: 2024-08-25 09:14:52

Pascal之工种问题的相关文章

(leetcode题解)Pascal&#39;s Triangle

Pascal's Triangle  Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 题意实现一个杨辉三角. 这道题只要注意了边界条件应该很好实现出来,C++实现如下 vector<vector<int>> generate(int

使用RemObjects Pascal Script (转)

http://www.cnblogs.com/MaxWoods/p/3304954.html 摘自RemObjects Wiki 本文提供RemObjects Pascal Script的整体概要并演示如何创建一些简单的脚本. Pascal Script包括两个不同部分: 编译器 (uPSCompiler.pas) 运行时 (uPSRuntime.pas) 两部分彼此独立.可以分开使用,或通过TPSScript 控件使用他们,这个控件定义在uPSComponent.pas单元,对这两个部分进行简

金矿模型看动归(PASCAL版)

原文地址:http://www.cnblogs.com/SDJL/archive/2008/08/22/1274312.html{PASCAL语言} 对于动态规划,每个刚接触的人都需要一段时间来理解,特别是第一次接触的时候总是想不通为什么这种方法可行,这篇文章就是为了帮助大家理解动态规划,并通过讲解基本的01背包问题来引导读者如何去思考动态规划.本文力求通俗易懂,无异性,不让读者感到迷惑,引导读者去思考,所以如果你在阅读中发现有不通顺的地方,让你产生错误理解的地方,让你难得读懂的地方,请跟贴指出

LeetCode (13) Pascal&#39;s Triangle (杨辉三角 )

题目描述 Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return 从第三行开始,每行除了最左边和最右边两个数为1,其他数字都是上一行中相邻两个数字之和.根据上述规则可以写出下面的代码: class Solution { public: vector<vector<int> > generateRow1() { vector<in

pascal,c,c++使用大于longint(long)的整型的方式

(pascal: pascal输出不需要说明格式,而式若子运算过程中的值都在qword范围内,则结果输出无错误. 1 begin 2 writeln(100000*100000); 3 writeln(100000*10000 mod 100); 4 end. c: 若运算结果为long long 或 __int_64,要在式子前加上(long long) 或 (__int_64) 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int

118. Pascal&#39;s Triangle

Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 分析 第k层有k个元素,每层第一个及最后一个元素值为1,对于(k>2)层,第n(n>1 && n < k)个元素A[k][n] = A[k-1][n-1]+A[k-1][n];

119. Pascal&#39;s Triangle II

Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to use only O(k) extra space? 1 class Solution { 2 public: 3 vector<int> getRow(int rowIndex) { 4 5 vect

Java [Leetcode 119]Pascal&#39;s Triangle II

题目描述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 解题思路: 每次在上一个list前面插入1,然后后面的每两个间相加赋值给前一个数. 代码描述: public class Solution { public List<Integer> getRow(int rowIndex) { List<Integer> r

PASCAL的优越性:官方的说法

也许你认为为什么我选择pascal代替其他的语言,像C.或者您会拿FreePascal和其他的pascal编译器作比较,那么好,这里您看看FreePascal为什么好: 1.pascal是一个非常简洁的语言,Pascal是一种非常优美的语言.比起C和C++来,你的程序可以具有很强的可读性和可维护性.并且pascal具有你所能想象到的强大的功能.2.不需要Makefile,不像很多的程序语言,Pascal 并不需要makefile文件,你能够节约大量的时间.编译器能够知道哪些文件需要编译.3.Pa