Recent

Author Topic: i have a exam tomorrow so can any one help me with this program guys i really ne  (Read 1654 times)

whitehat

  • Jr. Member
  • **
  • Posts: 93

remplir une matrice M de L lignes  et C colonnes par des entiers au hasard inférieur à 10 avec L est C multiple de 3
remplir un fichier intitulé "Somme.dat" qui va contenir la somme des cases de chaque ligne (SomL) et la somme des cases de chaque colone (SomC)
remplir un fichier texte intitulé "Pgcd.txt" par le pgcd de chaque couple de fichier "Somme.dat"
affichier les nombres premiers entre eux de fichier "somme.dat"
pour calculer le PGCD utiliser une procédé récursif
on dit que deux nombres sont premiers entre eux si leur PGCD est égal è 1

Code: Pascal  [Select][+][-]
  1. program ex;
  2. uses wincrt;
  3. type
  4. mat=array [1..20,1..20] of integer;
  5. fich=file of integer;
  6. var
  7. m:mat;
  8. n:integer;
  9. f:fich;
  10. fa:text;
  11. procedure remplire (var m:mat;n:integer);
  12. var
  13. i,j:integer;
  14. begin
  15. repeat
  16. writeln('donner n');
  17. readln(n);
  18. until (n < 6);
  19. for i:=1 to n do
  20. for j:=1 to n do
  21. m[i,j]:=random(10)+1
  22.  
  23. end;
  24. function some (var ch:string):integer;
  25. var
  26. i,j:integer;
  27. begin
  28. for i:=1 to n do
  29. for j:=1 to n do
  30. str(m[i,j],ch);
  31.  
  32.  
  33. end;
  34. procedure affiche (m:mat;n:integer);
  35. var
  36. i,j:integer;
  37. begin
  38. for i:=1 to n do
  39. for j:=1 to n do
  40. write(m[i,j]);
  41. end;
  42. begin
  43. assign(f,'c:\somme.dat');
  44. assign(fa,'c:\pgcd.txt');
  45. remplire (m,n);
  46. affiche(m,n);
  47.  
  48. end.
  49.  

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
whitehat, a donation to the community would be greatly appreciated.

Google Translate
Quote
Fill a matrix M of L rows and C columns by random integers less than 10 with L is C multiple of 3
Fill a file called "Somme.dat" which will contain the sum of the boxes of each row (SomL) and the sum of the boxes of each column (SomC)
Fill a text file called "Pgcd.txt" by the pgcd of each file pair "Somme.dat"
Display the prime numbers among them of file "sum.dat"
To calculate the PGCD use a recursive method
We say that two numbers are prime to each other if their PGCD is equal to 1


 

TinyPortal © 2005-2018