Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Project Euler 17 : Number letter count (1000)
//fpc 3.0.0 program HelloWorld; var i,n : integer; s: longint; begin s:=0; for i:=1 to 1000 do begin if i=1000 then s:=s+11; n:=i; case (i div 100) of 1: begin write('One hundred ');s:=s+10;end; // One hundred 2: begin write('Two hundred ');s:=s+10;end; 3: begin write('Three hundred ');s:=s+12;end; 4: begin write('Four hundred ');s:=s+11;end; 5: begin write('Five hundred ');s:=s+11;end; 6: begin write('Six hundred ');s:=s+10;end; 7: begin write('Seven hundred ');s:=s+12;end; 8: begin write('Eight hundred ');s:=s+12;end; 9: begin write('Nine hundred ');s:=s+11;end; end; if (i>100) and (i mod 100 <> 0) then begin write('and ' );s:=s+3;end; // One hundred and n:=n - (n div 100)*100; if n div 10 <> 1 then begin case (n div 10) of // Twenty 2: begin write('Twenty ');s:=s+6;end; 3: begin write('Thirty ');s:=s+6;end; 4: begin write('Forty ');s:=s+5;end; 5: begin write('Fifty ');s:=s+5;end; 6: begin write('Sixty ');s:=s+5;end; 7: begin write('Seventy ');s:=s+7;end; 8: begin write('Eighty ');s:=s+6;end; 9: begin write('Ninety ');s:=s+6;end; end; case (n mod 10) of // one 1: begin write('one ');s:=s+3;end; 2: begin write('two ');s:=s+3;end; 3: begin write('three ');s:=s+5;end; 4: begin write('four ');s:=s+4;end; 5: begin write('five ');s:=s+4;end; 6: begin write('six ');s:=s+3;end; 7: begin write('seven ');s:=s+5;end; 8: begin write('eight ');s:=s+5;end; 9: begin write('nine ');s:=s+4;end; end; end else case n of // Eleven 10: begin write('Ten ');s:=s+3;end; 11: begin write('Eleven ');s:=s+6;end; 12: begin write('Twelve ');s:=s+6;end; 13: begin write('Thirteen ');s:=s+8;end; 14: begin write('Fourteen ');s:=s+8;end; 15: begin write('Fifteen ');s:=s+7;end; 16: begin write('Sixteen ');s:=s+7;end; 17: begin write('Seventeen ');s:=s+9;end; 18: begin write('Eighteen ');s:=s+8;end; 19: begin write('Nineteen ');s:=s+8;end; end; writeln(i,' : ',s); end; write(s); end.
run
|
edit
|
history
|
help
0
2
Increase decrease
Régua Para tanque cilindrico horizontal
Matriz 9x9
zadacha3
Project Euler 20 - Factorial digit sum
perpus
вывод номера символа на экран
test07
sandogh 1