It looks like you're new here. If you want to get involved, click one of these buttons!

- 141.1K All Categories
- 103.8K Programming Languages
- 6.5K Assembler Developer
- 1.9K Basic
- 40K C and C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 4 Haskell
- 9.7K Java
- 4.1K Pascal
- 1.3K Perl
- 2K PHP
- 552 Python
- 37 Ruby
- 4.4K VB.NET
- 1.6K VBA
- 20.9K Visual Basic
- 2.6K Game programming
- 317 Console programming
- 93 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 746 Computer Hardware
- 3.5K Database & SQL
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 258 XML Development
- 3.3K Classifieds
- 199 Co-operative Projects
- 199 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 605 Jobs Wanted
- 212 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 3.4K Miscellaneous
- 7 Join the Team
- 356 Comments on this site
- 71 Computer Emulators
- 2.1K General programming
- 187 New programming languages
- 640 Off topic board
- 226 Mobile & Wireless
- 98 Android
- 126 Palm Pilot
- 340 Multimedia
- 156 Demo programming
- 184 MP3 programming
- Bash scripts
- 27 Cloud Computing
- 53 FreeBSD
- 1.7K LINUX programming
- 371 MS-DOS
- Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 944 Software Development
- 417 Algorithms
- 68 Object Orientation
- 92 Project Management
- 95 Quality & Testing
- 271 Security
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 62 AJAX
- 6 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 2.2K JavaScript
- 37 JQuery
- 309 WEB Servers
- 157 WEB-Services / SOAP

The mark table is as follows:

A = 80..100

B = 70.. 79

C = 60.. 69

D = 50.. 59

F = 0.. 49

X everything else

Input Format

Line 1: one integer T

Lines 2..T+1: one integer N

Output Format:

Lines 1..T: one character denoting the letter grade received

Input:

3

10

99

101

Output:

F

A

X

[/color]

[code]var

a,b:integer;

d: array [1..1000] of integer;

begin

readln(a);

for b:= 1 to a do

readln(d[b]);

for a:= 1 to a do

begin

if (d[b]>=80) and (d[b]<=100) then

writeln('A')

else if (d[b]>=70) and (d[b]<=79) then

writeln('B')

else if (d[b]>=60) and (d[b]<=69) then

writeln('C')

else if (d[b]>=50) and (d[b]<=59) then

writeln('D')

else if (d[b] >= 49) then

writeln('F')

else

writeln('X');

end;

readln;

end.

Terms of use / Privacy statement / Publisher: Lars Hagelin

Programmers Heaven articles / Programmers Heaven files / Programmers Heaven uploaded content / Programmers Heaven C Sharp ebook / Operated by CommunityHeaven

© 1997-2017 Programmersheaven.com - All rights reserved.

## Comments

447✭✭var

i,j:integer;

d: array [1..1000] of integer;

begin

readln(j);

for i := 1 to j do

readln(d[i]);

for [red]i[/red] := 1 to a j begin

if (d[i]>=80) and (d[i]<=100) then

writeln('A')

else if (d[i]>=70) and (d[i]<=79) then

writeln('B')

else if (d[i]>=60) and (d[i]<=69) then

writeln('C')

else if (d[i]>=50) and (d[i]<=59) then

writeln('D')

else if (d[i] [red]<=[/red] 49) [red]or (d[i] > 100)[/red] then

writeln('F')

else

writeln('X');

end;

readln;

end.

[/code]

Even better

[code]

var

i,j : integer;

d : array [1..1000] of integer;

begin

readln(j);

for i := 1 to i do

readln(d[i]);

for i := 1 to j do

if d[i] > 100 then

writeln('X')

else if d[i] >= 80 then [red]{ no need to test d[i] <= 100 since d[i] > 100 }[/red]

writeln('A') [red]{ has been eliminated by previous test }[/red]

else if d[i] >= 70 then

writeln('B')

else if d[i] >= 60 then

writeln('C')

else if d[i] >= 50 then

writeln('D')

else if d[i] >= 0 then

writeln('F')

else

writeln('X');

readln;

end.

[/code]

?

26The first line of input will be the number of test cases T (1 <= T <= 100). The following T lines will contain N. Output the cost in cents to mail the letter.

The pricing is as follows:

0 <= N <= 30 costs 38 cents

30 < N <= 50 costs 55 cents

50 < N <= 100 costs 73 cents

If N > 100 then the base cost is 73 cents, plus 24 cents for every additional 50 grams or part thereof.

Input:

2

5

101

Output:

38

97[/color]

[code]uses crt;

var

total,cost1,tt:integer;

a:array [1..100000] of integer;

begin

clrscr;

readln(tt);

for total:= 1 to tt do

readln(a[total]);

for total:= 1 to tt do

begin

if total<=30 then

writeln('38')

else if total<=50 then

writeln('55')

else if total<=100 then

writeln('73')

else if total>100 then

begin

cost1:= total-50;

writeln(73+24*(cost1 div 50));

end;

end;

readln;

end.[/code]

447✭✭: var

: total,cost1,tt:integer;

: a:array [1..100000] of integer;

:

:

: begin

: clrscr;

: readln(tt);

: for total:= 1 to tt do

:

: readln(a[total]);

:

: for total:= 1 to tt do

: begin

: if total<=30 then [red]{ think about it -- if tt <= 30 then }[/red]

: writeln('38') [red]{ '38' gets printed every time } [/red]

:

: else if total<=50 then

: writeln('55')

:

: else if total<=100 then

: writeln('73')

:

: else if total>100 then

: begin

: cost1:= total-50;

: writeln(73+24*(cost1 div 50));

: end;

: end;

:

: readln;

: end.[/code]:

:

:

:

:

[code]

uses crt;

var

i, t : 1 .. 100 ; [red]{ subrange of integer or byte }[/red]

n : 0 .. 200000 ; [red]{ subrange of longint - integer can only

go as high as 32767 }[/red]

cost : array [1 .. 100] of 0 .. 200000 ;

begin

clrscr;

readln(t);

for i := 1 to t do begin

readln(n);

if n <= 30 then

cost[i] := 38

else if n <= 50 then

cost[i] := 55

else if n <= 100 then

cost[i] := 73

else [red]{ n > 100 is only remaining possibility }[/red]

cost[i] := 73 + 24*(((n - 100) div 50) + 1)

end ;

for i := 1 to t do

writeln (cost[i]) ;

readln;

end.

[/code]

26N and M will be positive integers less than or equal to 1,000,000,000.

The difference between N and M will be less than or equal to 5,000,000.

Sample Input

5 20

Sample Output

5

7

11

13

17

19[/color]

[color=Red]

and BTW thankx a lot for all your help!!! [/color]

[code]uses crt;

CONST

N = 100;

Var

P : Array [1 .. N] of boolean ;

i,q,j,m : longint;

begin

clrscr;

readln(i);

readln(q);

for i := 1 TO N do

P[i] := TRUE;

m := trunc(sqrt(N)) ;

for i := 2 to m do

if P[i] then

for j := 2 to N DIV i do

P[i * j] := FALSE ;

for i := 1 to q do

if P[i] then

if i>=r then

begin

writeln(i) ;

end;

readln

end.

[/code]

447✭✭uses crt;

CONST

N = 100;

Var

P : Array [1 .. N] of boolean ;

i,j,m,q,[red]r[/red] : longint; [red]{ declare r - didn't compiler catch this? }[/red]

begin

clrscr;

readln([red]r[/red]); [red]{ readln(r), not readln(i) }[/red]

readln(q);

for i := 1 TO N do

P[i] := TRUE;

[red]{

Sieve of Aristosthenes - good approach, but putting the

sieve in an array won't work for large N because memory

won't hold it. For large N you'll have to use a file.

}[/red]

m := trunc(sqrt(N)) ;

for i := 2 to m do

if P[i] then

for j := 2 to N DIV i do

P[i * j] := FALSE ;

for i := 1 to q do

if P[i] then

if i >= r then

begin

writeln(i) ;

end;

readln

end.

[/code]

268[code][color=Blue]

program primes;

const max_val{ue}=1000000000;

max_dif{ference}=5000000;

mv:array[1..4] of byte=(2,3,5,7);

function is_prime(l:longint):boolean;

var l2:comp; {very large integer, to support square of max_value}

i:longint;

m:byte;

begin

for m:=1 to 4 do

if (l mod mv[m]=0) then begin

is_prime:=(l=mv[m]);

exit;

end;

l2:=mv[4];

while sqr(l2)min_v) and (max_v-min_v<=max_dif));

writeln;

n:=0;

for t:=min_v to max_v do

if is_prime(t) then begin

writeln(t);

inc(n);

end;

writeln(n,' number of primes found');

end.

[/color][/code]

26268:

Wait a few years, then run the code on an entry level PC...:-)

757[code]

while i<l2 do begin

inc(i,2);

[/code]

can be changed to:

[code]

while i < (l2 DIV 2) do begin

inc(i,2);

[/code]

however this is slow, so we use a shift instead:

[code]

while i < (l2 SHR 1) do begin

inc(i,2);

[/code]

Also, I would suggest that your main procedcure increments the prime checks by two and therefore only needs to do half the amount of function calls (slow).

268