Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. program delete;
  2. const lmax=100;
  3. var
  4. Z:array[1..lmax,1..lmax] of integer;
  5. P:array[1..lmax] of integer;
  6. i,j,n,m,k,num,cur:integer;
  7. nr,mr,kr:real;
  8. flag:boolean;
  9. begin
  10. writeln('Лабораторная работа №2');
  11. writeln('Задание №1');
  12. repeat
  13. writeln('Введите размеры матрицы Z от 1 до ', lmax);
  14. readln(nr,mr);
  15. until (nr=round(nr)) and (mr=round(mr)) and
  16. (nr<=lmax) and (mr<=lmax) and
  17. (nr>0) and (mr>0);
  18. n:=round(nr);
  19. m:=round(mr);
  20. writeln('Введите элементы матрицы Z');
  21. for i:=1 to n do
  22. for j:=1 to m do
  23. read(Z[i][j]);
  24. writeln;
  25. repeat
  26. writeln('Введите длину массива P от 1 до ', lmax);
  27. readln(kr);
  28. until (kr=round(kr)) and (kr<=lmax) and (kr>0);
  29. k:=round(kr);
  30. writeln('Введите элементы массива P');
  31. for i:=1 to k do
  32. read(P[i]);
  33. writeln;
  34. num:=0;
  35. for j:=1 to m do
  36. begin
  37. cur:=1;
  38. flag:=false;
  39. while (cur<=n) and (not flag) do
  40. begin
  41. i:=1;
  42. while (i<=k) and (not flag) do
  43. begin
  44. if Z[cur][j]=P[i] then
  45. flag:=true;
  46. i:=i+1;
  47. end;
  48. cur:=cur+1;
  49. end;
  50. if flag then
  51. begin
  52. num:=num+1;
  53. for i:=1 to n do
  54. Z[i][num]:=Z[i][j];
  55. end;
  56. end;
  57. if num=0 then
  58. writeln('Вся матрица была удалена')
  59. else
  60. begin
  61. writeln('Полученная матрица');
  62. for i:=1 to n do
  63. begin
  64. for j:=1 to num do
  65. write(Z[i][j]:5);
  66. writeln;
  67. end;
  68. if num=m then
  69. writeln('Ни один столбец матрицы не был удален');
  70. end;
  71. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement