Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Operazioni matematiche - Operaz_Matematiche.pas

Operaz_Matematiche.pas

Caricato da: Totipianurese
Scarica il programma completo

  1. program Operaz_matematiche;
  2. uses crt;
  3. var a: array[1..1000]of integer;
  4.     b: array[1..1000]of integer;
  5.     i,MaxLung,som,n1,k,scelta,base,esp,pot,n,leggi:integer;
  6.     mediapon:real;
  7.     numeri : array [1..10000] of longint;
  8.     Somma,Media,fatt:real;
  9.     numero,meta,conta:integer;
  10.  
  11. procedure home;
  12.  begin
  13.   repeat
  14.   clrscr;
  15.   textcolor(7); textbackground(black);
  16.   clrscr;
  17.   for i:=1 to 80 do write(char(205));
  18.   for i:=1 to 24 do
  19.                   begin
  20.                   gotoxy(1,i);
  21.                   write('|');
  22.                   end;
  23.   for i:=1 to 24 do
  24.                   begin
  25.                   gotoxy(80,i);
  26.                   write('|');
  27.                  end;
  28.   for i:=2 to 79 do
  29.                  begin
  30.                  gotoxy(i,24);
  31.                  write(char(205));
  32.                  end;
  33.   for i:=2 to 79 do
  34.                   begin
  35.                   gotoxy(i,5);
  36.                   write(char(205));
  37.                   end;
  38.   for i:=2 to 79 do
  39.                   begin
  40.                   gotoxy(i,20);
  41.                   write(char(205));
  42.                   end;
  43.   gotoxy(34,3); write('TotiPianurese');
  44.   gotoxy(31,7); write('1- Media semplice');
  45.   gotoxy(31,9); write('2- Media ponderata');
  46.   gotoxy(31,11); write('3- Elevamento a potenza');
  47.   gotoxy(31,13); write('4- Fattoriale');
  48.   gotoxy(31,15); write('5- Divisori di N');
  49.   gotoxy(35,22); write('Scelta --> ');read(scelta);
  50.   until ((scelta<6)and(scelta>0));
  51.  end;
  52.  
  53.  procedure instr;
  54.  begin
  55.  leggi:=0;
  56.  writeln;
  57.  writeln;
  58.  textcolor(15);
  59.  writeln('Inserisci un numero per tornare indietro');
  60.  textcolor(3);
  61.  write('                                                          Copyright Toty');write(' ',char(169));
  62.  writeln;
  63.  readln(leggi);
  64.  end;
  65.  
  66.  
  67. begin
  68. repeat
  69. home;
  70. if scelta=1 then
  71.              begin
  72.              repeat
  73.              clrscr;
  74.              k:=7;
  75.              textcolor(5);
  76.              for i:=1 to 80 do write(char(205));
  77.              gotoxy(31,2);
  78.              textcolor(lightblue);
  79.              writeln('MEDIA SEMPLICE');
  80.              textcolor(5);
  81.              for i:=1 to 80 do write(char(205));
  82.              gotoxy(1,5);
  83.              textcolor(yellow);
  84.              write('Inserisci il numero degli elementi di cui devi conoscere la media = ');
  85.              readln(MaxLung);
  86.              until MaxLung>1;
  87.              for i := 1 to MaxLung do
  88.                                    begin
  89.                                     textcolor(13);
  90.                                     gotoxy(1,k);
  91.                                     write('Inserisci il ',i,'ø numero = ');
  92.                                     readln (numeri [i]);
  93.                                     Somma := Somma + numeri [i];
  94.                                     k:=k+1;
  95.                                    end;
  96.              Media := Somma/MaxLung;
  97.              k:=k+1;
  98.              gotoxy(1,k);
  99.              textcolor(lightgreen);
  100.              write('La media Š ',Media :2:2);
  101.              instr;
  102.              end;
  103.  
  104. if scelta=2 then
  105.              begin
  106.              repeat
  107.              textbackground(7);
  108.              clrscr;
  109.              n1:=0;
  110.              som:=0;
  111.              textcolor(5);
  112.              for i:=1 to 80 do write(char(205));
  113.              gotoxy(33,2);
  114.              textcolor(11);
  115.              writeln('MEDIA PONDERATA');
  116.              textcolor(5);
  117.              for i:=1 to 80 do write(char(205));
  118.              writeln;
  119.              textcolor(yellow);
  120.              write('Da quanti numeri Š composta la lista di cui devi conoscere la media = ');
  121.              readln(MaxLung);
  122.              until MaxLung>1;
  123.              k:=6;
  124.              for i:=1 to MaxLung do
  125.                                  begin
  126.                                  textcolor(black);
  127.                                  gotoxy(1,k);
  128.                                  write('Inserisci il ',i,'ø numero = ');read(a[i]);
  129.                                  k:=k+1;
  130.                                  textcolor(lightblue);
  131.                                  gotoxy(1,k);
  132.                                  write('Quante volte troviamo il ',i,'ø numero = '); read(b[i]);
  133.                                  k:=k+1;
  134.                                  som:=som+a[i]*b[i];
  135.                                  n1:=n1+b[i];
  136.                                  end;
  137.              mediapon:=som/n1;
  138.              writeln;
  139.              k:=k+2;
  140.              gotoxy(1,k);
  141.              textcolor(lightred);
  142.              writeln('La media ponderata Š ',mediapon:0:2);
  143.              instr;
  144.              end;
  145.  
  146. if scelta=3 then
  147.              begin
  148.              pot:=1;
  149.              clrscr;
  150.              textcolor(lightred);
  151.              for i:=1 to 80 do write(char(205));
  152.              gotoxy(28,2);
  153.              textcolor(11);
  154.              writeln('ELEVAMENTO A POTENZA');
  155.              textcolor(lightred);
  156.              for i:=1 to 80 do write(char(205));
  157.              textcolor(15);
  158.              gotoxy(1,5); write('Inserisci il numero BASE = ');
  159.              readln(base);
  160.              gotoxy(1,8); write('Inserisci l''esponente = ');
  161.              readln(esp);
  162.              for i:=1 to esp do
  163.                              pot:=pot*base;
  164.              textcolor(9);
  165.              gotoxy(1,11); write('ELEVAMENTO = ',pot);
  166.              instr;
  167.              end;
  168.  
  169. if scelta=4 then
  170.              begin
  171.              clrscr;
  172.              textcolor(2);
  173.              for i:=1 to 80 do write(char(205));
  174.              gotoxy(35,2);
  175.              textcolor(4);
  176.              writeln('FATTORIALE');
  177.              textcolor(2);
  178.              for i:=1 to 80 do write(char(205));
  179.              textcolor(11);
  180.              fatt:=1;
  181.              gotoxy(1,5);
  182.              repeat write('Inserisci il numero da fattorializzare = ');
  183.              readln(n);
  184.              if n=0 then
  185.                     writeln('Il fattoriale di 0 Š ',fatt:0:2);
  186.              until n>0;
  187.  
  188.              for i:=2 to n do
  189.                            begin
  190.                            fatt:=fatt*i;
  191.                            end;
  192.              writeln;
  193.              textcolor(lightgreen);
  194.              writeln('Il fattoriale di ',n,' Š : ', fatt:0:2);
  195.              instr;
  196.              end;
  197.  
  198. if scelta=5 then
  199.              begin
  200.              repeat
  201.              clrscr;
  202.              conta:=0;
  203.              textcolor(11);
  204.              for i:=1 to 80 do write(char(205));
  205.              gotoxy(33,2);
  206.              textcolor(lightblue);
  207.              writeln('DIVISORI DI N');
  208.              textcolor(11);
  209.              for i:=1 to 80 do write(char(205));
  210.              gotoxy(1,5);
  211.              textcolor(15);
  212.              write('Digita un numero diverso da 1 per conoscerne i divisori = ');
  213.              readln(numero);
  214.              until numero>1;
  215.              meta:=numero div 2;
  216.              for i:=1 to numero do
  217.                                 begin
  218.                                 if (numero mod i)=0 then
  219.                                                      conta:=conta+1;
  220.                                 end;
  221.              if conta=2 then
  222.                          begin
  223.                          writeln;
  224.                          textcolor(13);
  225.                          writeln('Il numero non ha divisori (oltre 1 e se stesso)');
  226.                          instr;
  227.                          end
  228.                          else
  229.                          begin
  230.                          for i:=2 to meta do
  231.                                           begin
  232.                                           if (numero mod i)=0 then
  233.                                                                begin
  234.                                                                textcolor(13);
  235.                                                                writeln(i,' Š un divisore');
  236.                                                                end;
  237.                                           end;
  238.                          instr;
  239.                          end;
  240.              end;
  241.  
  242. until leggi<0;
  243.              readln();
  244.              readln();
  245.  
  246.   end.