top of page



Public·6 members

Program Queue Pascal

Hi all :-) I am making a program about queues that will enable the user to add, view and delete data from the queue with out the user of pointers. So far I have coded the following code but I need some advice on what to do next. I have already had some advice from some people but unfortunately they all refered to pointers. My Computing A-level book also seems to give the impression that the queues program is possible without pointers e.g. ^nodeptr. Anyway here is the code so far and thanks in advance:- program queues; uses crt; Shiva Naicken const limit = 10; type queue = record item : array [1..limit] of string; front:integer; rear:integer; size:integer; end; var q:queue; choice : integer; procedure initialise; begin q.front:=0; q.rear:=0; q.size:=0; end; procedure view; var loop:integer; begin clrscr; for loop:=1 to limit do writeln (q.item[loop]); end; procedure add; var data : string; begin writeln('Input the data to be placed in the queue: '); readln(data); with q do if q.size = limit then writeln('QUEUE OVERFLOW') else end; procedure remove; begin end; begin initialise; repeat clrscr; writeln('Queues :-)!!!!!'); writeln('1. View Queue'); writeln('2. Add data to queue'); writeln('3. Remove data from Queue'); writeln('4. Exit'); readln(choice); if choice = 1 then view; if choice = 2 then add; if choice = 3 then remove; until choice = 4; end. Stephen Wed, 18 Jun 1902 08:00:00 GMT Ing. Franz Glase#2 / 3 Queues in Pascal without pointers If it is a queue literally, you don't need static pointers (indicex) at all. Better define a Type QeRec = Record filled : Boolean; txt : String; End; Var Queue = Array[0..10] of QeRec; Procedure Add(NewText : String); (* at the bottom of the serpent *) Var I : Integer; Begin if Queue[10].filled then Begin Errormessage.... no more space Exit; End; for I := 10 downto 1 do (* down is necessary not to overwrite all *) Queue[I] := Queue[I-1]; Queue[0].txt := NewText; Queue[0].filled := true; End; Procedure Remove; (* at the upper end of the serpent *) Var I : Integer; Begin if not Queue[0].filled then Begin Errormsg... nothing to remove Exit; (* important, else below would possibly crash *) End; I := 10; while not Queue[I].filled do I := I-1; (* or Dec(I); *) if I >= 0 then (* this IF is not really necessary*) Queue[I].filled := false; End; Procedure Initialize; Begin fillchar(Queue,sizeof(Queue),#0); End; Begin Initialize; .... End. NOTE: This is one possible solution, maybe not the best, but it reflects best the queue behaviour to have no static counters / pointers (here not meant as adress - pointers but index into the array). Kindest Regards, Franz Glaser, Austria please visit my URL -glaser computer_2(); Wed, 18 Jun 1902 08:00:00 GMT Frank Peel#3 / 3 Queues in Pascal without pointers Quote: >Hi all :-) >I am making a program about queues that will enable the user to add, view >and delete data from the queue with out the user of pointers. So far I >have coded the following code but I need some advice on what to do next. I >have already had some advice from some people but unfortunately they all >refered to pointers. My Computing A-level book also seems to give the >impression that the queues program is possible without pointers e.g. >^nodeptr. Anyway here is the code so far and thanks in advance:- > [source code snipped] Sorry this is late. Queues can be done in an array no problem. You need to work out the queue size and whether the queue is full from the relative positions of the front and rear indices. I assume rear is where an item joins the queue and front is the next element to be taken off. You initialise these to 0 so obviously you have decided that the queue is empty when front=rear and full when rear=front-1 allowing for wraparound. You can use modulo arithmetic to allow for wraparound, in other words the "full" condition is ((Rear+1) mod limit) = Front. You have to be careful to use +ve values with mod because for -ve values the mod operator in computer languages differs from what would normally expect with modulo arithmetic. Since x mod limit has a value [0..limit-1] it is convenient if the array goes 0..limit-1 as well. This would also fit better with front and read being initialised to 0. Since the pointer indices are defined this way (front=rear => empty), item [front] is the next item to be removed from the queue and item[rear] is where the next item _will_ go - it is not in use yet. Therefore the queue can have at most limit-1 elements. At that point rear will be front-1 but if you add the next element rear will catch up on front which is not allowed. The View method should start with item[Front] and loop until you reach item[rear] - you don't really want to go over the whole array if you want to display the queue. I don't think the condition for the queue being full is very obvious, and if you change your implementation it might change, so it might be a good idea to have a function isFull or something like that to put the condition in. That way if you get it wrong you fix it in just one place rather than everywhere you have "if q.size=limit" - which is wrong, should read "limit-1". Also size could be a function so you wouldn't have to maintain that variable all over the place. If queue was an object rather than a plain record you could make size a method and then you would use it the same way as you do now (e.g. writeln('the queue has ',q.size,' elements');) Also initialise, view, add and remove could be methods so you wouldn't have to put "q." in there. As a bonus you would then be able to have more than one queue (var q, w:queue) which you can't with "q." all over the place. Finally you have a lot of clrscrs in there which will clear e.g. messages like the QUEUE OVERFLOW one before you can see them if your machine is any way fast! FP Wed, 18 Jun 1902 08:00:00 GMT Page 1 of 1 [ 3 post ] Relevant Pages 1. Multiple queues w/pointers!

Program Queue Pascal

This will "queue" the given method with the given parameter for execution in the main event loop, when all other events have been processed. In the example above, the reference to the object you wanted to free has gone, since the then-parent has finished execution, and the object you wanted to free can be freed safely.

The following program shows the use of QueueAsyncCall. If you press on the CallButton, 'Click 1', 'Click 2' and 'Async 1' is added to the LogListBox. Note that Async call is only executed after the CallButtonClick event has finished.

In the Pascal programming language, the assignmentoperator is the two character sequence :=instead of a single = character as in Java.Write a program that reads in a source file line by line.Each sequence:= in a line is changed into = before the line is output. (Of course, much more than this is needed to fully translatePascal to Java.)Use redirection for file input and output:

Hints: use a Scanner and nextLine()for input.The outer while loop of the program uses hasNextLine() to decide if it should continue.Use indexOf() to look for :=.Use substring() and concat() (or +)to create the transformed line.

An if statement or a while statementin Java should usually not containthe character =,unless it is part of ==, =, or !=.Sometimes, however, a single = is correct.Write a program that reads in a Java source program line by line andoutputs only those lines that start with "if" or "while" (possibly preceded by whitespace) and thatsomewhere contain a single equal sign with at least one spaceon the left and right: " = " .The user can then inspect each line of the output for problems.A much better program would detect a single "=" even when not surrounded by spaces,but that is much harder to write.

The English, words "a" and "the" can mostly be removed from sentenceswithout affecting the meaning.This is an opportunity for compressing the size of text files!Write a program that inputs a text file, line-by-line, and writes outa new text file where each line has the useless words eliminated.

First write a simple version of the programthat replaces substrings " a " and " the " in each line with a single space.This will remove many words, but sometimes these words occur at thebeginnings or ends of lines, and sometimes the words start with capitals.So, improve your first program so that it handles those situations as well.

Write a program that decodes a secret message contained in a text file.The first line of the text file contains the key-phrase.Then the file contains a sequence of integers, each of which indexesthe key-phrase.Find the character corresponding to each integer and output the secret message.Note if a character character such as 'e' occurs several places in the key-phraseit may be encoded as different integers in different parts of the secret message.

Now, hold tight because you are going to be amazed by this fact. Each element in Pascal's Triangle can be calculated using the element's row and column number. For example, the value of the element in the third row and second columns will be equal to 2C1, which is 2. Note how the row and column numbers are subtracted by 1 while calculating the value. This is because counting in programming starts from 0 and not from 1. Look at the image below, to have a clearer understanding. 350c69d7ab


Welcome to the group! You can connect with other members, ge...


                                                                          “ 白纸抗议”昭示着中国新一代公民意识的觉醒!


  思乡心切的老伴儿几乎每一天都要跟她在这个世界上最亲近的人, 她的亲姐姐,也是我的大姨子​通电话。一向性格外向,率直健谈的大姨子姐几天前突然不接电话,令老伴儿万分紧张。给外甥通电话后才知道大姨子姐下楼去超市买把儿香菜,突然被几个大白架上囚车一样的防疫运输车拉走了。目的地是郊县的一个隔离中心。
        听到这个消息, 我和老伴儿都傻了。心中的忧虑和怒火油然而生。 这是甚麽国家, 甚麽政府, 甚麽官员, 竟敢如此胆大包天, 无视公民最基本的人权, 肆意践踏公民的尊严, 自由甚至人身安全? 这与土匪横行的旧中国有何差别?!
两天后,我们就看到了发生在新疆乌鲁木齐市十人被大火活活烧死的悲惨新闻。 翌日, 乌鲁木齐市就爆发中国自抗疫以来第一场公民抗命群体事件。紧接着就是上海, 兰州, 广州, 北京, 和其他一些城市年轻学生以及市民自发的抗议活动。 随着推特, 抖音和Tiktok 以及有关相关视频的展示, 一出出, 一幕幕曾经多么熟悉的景象又展现在我的眼前。
       在此之前, 通过中国国内的抖音,快手以及微视等社交平台我已经看到了在中国各地出现的中国防疫毫无人性的乱象和令人愤慨的“官员”行为。在这些短录像中, “大白” 不给任何解释随意封控居民小区, 强行私闯民宅“消毒”,拉人, 骂人, 打人。 中华人民共和国的合法公民在二十一世纪迎接中华民族复兴的伟大时刻却令人心寒的迎来了人人噤若寒蝉, 人人与邻为壑, 人人各自举报, 人人互相猜忌仇恨的“文革”岁月!
      曾几何时, 我等海外华人为中国政府科学, 快速, 高效和亲民的防疫抗疫高声喝彩。 为了反击西方媒体对中国肆意的抹黑,歪曲和造谣, 我开通了自己的Tiktok, Reel 和Shorts, 夜以继日的上传祖国在抗击疫情, 科学技术和人文关怀所取得任何进步, 还专门配上英语解说。 不到三个月就收获五万多粉丝, 点赞数超过三百万。 中国太空人顺利进入空间站我流泪,比亚迪电动车又传销售捷报我欢呼雀跃, 陈薇博士又研制出了新的疫苗我开心一晚上。 一晃儿严格的防疫抗疫到了第三个年头。 眼见的善良, 柔顺和勤劳的中国老百姓从合作,苦中作乐, 配合, 坚持,到了今天的无奈, 绝望和愤怒。而解决目前中国防疫困局的药方很简单, 哪就是体谅百姓的困苦, 依照与时俱进的原则逐渐放开管制,并对因防疫封孔而造成生活困顿的家庭以及个人进行政策扶助救济,推迟车贷, 房贷, 卡贷等债务的支付, 严格监管断供房产的法拍,法没和租客权益维护,并开通政府监管热线, 让在防疫抗疫中受到不合法,不公正, 不人道对待的群众即时举报,控诉和申诉。但是, 一向标榜“民之所忧,我必念之。 民之所盼, 我必行之”的中国政府高层除了一味的强调严控疫情,动态清零以外,对百姓的拮据和困苦始终无动于衷, 而地方政府以及官员更是冷酷无情,甚至人性尽失。 动辄强行拉人, 封门关户,造成了多少妻离子散,家庭破损。而政府的公务员更好似封建社会的衙门恶役,对百姓恣意打骂,侮辱。。。这一一切切让我怀疑这是不是新中国, 中华人民共和国?
      常言道: 水宜疏不宜堵。水如此, 民意岂不更是如此? 当乌鲁木齐传来烧死人的惨案而全国百姓和青年学生有怨言的时候, 中国政府应该由国务院出面对全国民众道歉, 并迅速提出因应措施和救助方案, 并以此为鉴, 顺应民意改善先行的已经弊端百出的防疫政策。 如此, 全国人民必然感到民众有心声, 政府有回应。 官民一条心, 共同迎胜利。 而现实是什么呢? 军警上街, 坦克出更,当街抓人, 官媒胡喷。民众和学生自发的小群体抗议发生成了受“境外反华势力”的煽动, 意图发动新时代“颜色革命”。 真是滑天下之大稽, 愚不可及! 一手好牌让这样的独裁, 傲慢, 残酷的政府打了个稀巴烂!
      这两天我翻看各种新闻, 中国航天人又顺利进入了中国人自己的空间站。以前网上这类新闻的点赞数瞬间几万, 几十万, 几百万。 每一个中国人不管身处何地都为中国取得的伟大成就高歌喝彩, 倍感自豪。 而今天, 我不出意外地发现没有什么人对这个新闻再感兴趣了。当然在卡达尔的足球世界杯比赛固然吸引了很多人的注意力, 但是更大的原因我想则是人们对今日之中国已经大失所望。是呀, 当一个国家对自己的百姓毫不在乎, 任意欺压和迫害的时候,又有谁会关心这样的“喜讯”? 一个"进步“和”发展“的中国在正在满腔愤懑,生活困苦的老百姓面前又有何用?
       我从来不敢低估美国”中情局“和形形色色的NGO非政府组织策反甚至颠覆其他国家政权的能力, 也从不否认西方媒体造谣抹黑中国政府的恶劣行为, 因为我曾经和他们正面干过架。但是, 如果中国政府如今非把当下的”白纸抗议“活动说成是部分群众和学生受到了所谓”境外势力“的指使和煽动, 就如同几年前的香港"黑暴”事件一样, 我十二万分的不同意。被政府的抗疫防疫政策严格封控了三年的中国老百姓通过各种媒体也认识到了新冠病毒的蜕变以及世界其他各国的现实状况,逐渐感到中国作为世界“抗疫孤岛”的荒唐与不合理之处, 再加上三年的不正常生活, 封控, 静默, 禁行以及收入剧减,人们对中国政府的现行政策已经从绝对的服从, 配合, 遵令到抵触; 大众的心里从苦中作乐, 无可奈何到愤怒失常。中国政府应该做的体谅人民的苦衷, 感激民众的配合, 补偿人民的损失, 照顾百姓的生活, 疏导失常的心理。而绝非今天的严厉谴责, 暴力惩罚和课以刑责!
      中国改革开放已经四十年有余。 中国亿万百姓早就不是迟钝,愚昧和无知的封建后人, 而是在现代媒体和自我学习加持下觉醒的一代。人间的善与恶, 丑与美,恨与爱, 是与非等早已了然于胸。为什麽不断标榜在科学技术上不断超越欧美西方国家的中国政府并不认为自己的国民已经在人文思想领域也早已经成熟并超越了所谓的“境外势力”了呢?


bottom of page