Program skroty(output); {type skr=string[5];} var pl:ansistring; wr,d,licz,i,l,il:longint; w1:array[0..25] of longint; w2:array[0..675] of longint; w3:array[0..17575] of longint; w4:array[0..456975] of longint; {skrs: array[1..100000] of skr;} s1,s2,s3,s4,ass:string; z1,z2,z3,z4,ac:char; function oblicz1(var sk1:string):integer; var a1s:char; begin a1s:=sk1[1]; oblicz1:=ord(a1s)-65; end; Function oblicz2(var sk2:string):integer; var a1s, a2s:char; wart:integer; begin a1s:=sk2[1]; a2s:=sk2[2]; wart:=(ord(a1s)-65)+26*(ord(a2s)-65); oblicz2:=wart; end; Function oblicz3(var sk3:string):integer; var a1s, a2s, a3s:char; wart:integer; begin a1s:=sk3[1]; a2s:=sk3[2]; a3s:=sk3[3]; wart:=(ord(a1s)-65)+26*(ord(a2s)-65)+26*26*(ord(a3s)-65); oblicz3:=wart; end; Function oblicz4(var sk4:string):longint; var a1s, a2s, a3s, a4s:char; wart:longint; begin a1s:=sk4[1]; a2s:=sk4[2]; a3s:=sk4[3]; a4s:=sk4[4]; wart:=(ord(a1s)-65)+26*(ord(a2s)-65)+26*26*(ord(a3s)-65)+26*26*26*(ord(a4s)-65); oblicz4:=wart; end; {**************************** GŁÓWNY **********************************} begin for i:=0 to 25 do w1[i]:=0; for i:=0 to 675 do w2[i]:=0; for i:=0 to 17575 do w3[i]:=0; for i:=0 to 456975 do w4[i]:=0; readln(pl); readln(il); d:=length(pl); pl:=pl+'@@@'; for i:= 1 to d do begin z1:=pl[i];z2:=pl[i+1];z3:=pl[i+2];z4:=pl[i+3]; s1:=z1;s2:=z1+z2;s3:=z1+z2+z3;s4:=z1+z2+z3+z4; wr:=oblicz1(s1); w1[wr]:=w1[wr]+1; wr:=oblicz2(s2); if wr>=0 then w2[wr]:=w2[wr]+1; wr:=oblicz3(s3); if wr>=0 then w3[wr]:=w3[wr]+1; wr:=oblicz4(s4); if wr>=0 then w4[wr]:=w4[wr]+1; end; for i:=1 to il do begin licz:=0; readln(ass); l:=length(ass); case l of 1: begin licz:=oblicz1(ass); writeln(w1[licz]); end; 2: begin licz:=oblicz2(ass); writeln(w2[licz]); end; 3: begin licz:=oblicz3(ass); writeln(w3[licz]); end; 4: begin licz:=oblicz4(ass); writeln(w4[licz]); end; end; {writeln(licz);} end; end.
program Beta; var hp,mhp:integer; MN:string; function Monster:string; begin Monster:='Demon'; MN:=Monster; mhp:=1000; writeln(' 1010101 10101010 '); writeln(' 10 011 101 10 '); writeln('1 0 1010 0 1 '); writeln(' ########## '); writeln(' # ## # '); writeln(' # # '); writeln(' ##l##l## '); writeln(' l l '); writeln(' 101010101010 AA 10101010101010 '); writeln(' 10101 ---- AA ----- 10101 '); writeln(' 01010 ---- ----- 01010 '); writeln(' 10101 ---- ----- 10101 '); writeln(' 01010 ---- AA ----- 01010 '); writeln;writeln;writeln; end; procedure Combat; begin writeln(MN); end; begin hp:=100; writeln(Monster,'is Coming!!!!!!'); Combat; end.
(*Name: Yogesh Byanjankar Course: CSCI 3010 Spring 2019 Summary: The purpose of this program is to read STDIN containing the number of candidates and the number of votes that each received and find the winner with highest number of votes. Date: 27 March 2019*) Program ElectionResults; uses sysutils; type arrayOfElection = array[1..100] of integer; arrayOfName = array[1..100] of String; arrayOfPercentage = array[1..100] of real; var votes1 : arrayOfElection; percentage1 : arrayOfPercentage; name1 : arrayOfName; (*this function returns the total number of votes*) function totals(voting : array of integer; counts : integer): integer; (*local vairables*) var i, total1 : integer; begin total1 := 0; for i := 0 to counts-1 do //loop starts from 0 begin total1 := total1 + voting[i]; end; totals := total1 ; //returns the total number of votes end; (*this function returns the winnerr of the election*) function print(voting : array of integer; counts : integer): integer; (*local vairables*) var maximum, i,indexOfmaximum : integer; begin maximum := 0; //initialize maximum to 0 for i := 0 to counts-1 do //loop starts from 0 begin (*compares all the votes to find maximum*) if (voting[i]>= maximum) then begin maximum := voting[i]; //the maximum votes indexOfmaximum := i; //finds the index of with maximum votes end; end; print := indexOfmaximum ; //returns the Last name of the winner end; (*prints the last name, votes received ,percent of total votes, and the winner of election in the election*) procedure runElection(var votes : arrayOfElection; var names : arrayOfName; var percent : arrayOfPercentage); (*declare local variables*) var j, count, total : integer; str, winner: string; begin writeln(format('%-18s%-18s%-18s', ['Candidate', 'Votes Received','% of Total Votes'])); //header display readln(count); //stores the total number of lines for j := 1 to count do //loop from 1 to count begin readln(names[j]); //read next line and stores in the names array in current index readln(votes[j]); //read next line and stores in the votes array in the current index end; total := totals(votes, count); (*loop starts*) for j := 1 to count do begin percent[j] := ((votes[j]/total) * 100 ); //calculates percent vote and stores in the percent array str := format('%-13s%13d%18.2f', [names[j], (votes[j]), (percent[j])]); //formats string writeln(str); //display the last name, votes, and the percentage of vote end; winner := names[print(votes, count) + 1]; writeln(format('%-13s%13d', ['Total', total])); //displays the total number of votes in given format writeln('The winner of the election is ' + winner + '.'); //displays the winner of the election end; begin {main program} runElection(votes1, name1, percentage1); end.
program tabellina_vettori; var i,n,r:integer; vett:array[1..10]of integer; begin writeln('prego,inserire il numero di cui vuoi la tabellina'); readln(n); for i:=1 to 10 do begin r:=n*i; vett[i]:=r; write(vett[i],'|'); end; end.
Program Reverse_num; var n,rev:integer; begin rev:=0; writeln('Input a number'); readln(n); while n>0 do begin rev:=rev*10+(n mod 10); n:=n div 10 end; writeln('The number in reverse order is ',rev); end.
uses crt; const DINHMUC=50; var m:integer; Function TIENDIEN(m:integer):longint; begin if m > DINHMUC then TIENDIEN:=DINHMUC*1900 + (m- DINHMUC)*8000 else TIENDIEN:=m*1900; end; Begin clrscr; writeln('Nhap so kWh dien da su dung trong thang: '); readln(m); writeln('So tien dien phai tra trong thang: ',TIENDIEN(m)); readln; End.
program testpassword; var password : integer ; number :boolean; begin writeln('please input your password:'); readln(password); number:=false; while (password <> 90783) or (number = false) do begin if (password= 90783) then number :=true; else writeln('The password is not correct,please enter again'); if (password= 90783) then ; number:= true; writeln('The password is correct .You can access the system'); end; writeln('The password is correct .You can access the system'); end
Program 12345; var num, ans, x : integer; begin writeln('Number of terms?'); readln(num); x := 1; ans := 0; while num > 1 do begin ans := ans + x; x := x*10+1; num := num-1; end; writeln('answer is ', x); end.
Program testpassword; var password : integer; number:boolean; begin writeln('Please enter the password:'); readln(password); number:=false; while (password <> 90783) or (number = false) do begin if (password=90783) then number:=true; else writeln ('sorry the password is not correct,pleaseenter again'); writeln('Please enter the password:'); readln(password); end; writeln('The password is correct.You can access the system'); end.
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more