Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdio.h>
  4. #include <iomanip>
  5. #include <math.h>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. setlocale(LC_ALL, "Russian");
  11. int a,b,c,n,m,i,j,s1=0,s2=0;
  12. int A[100][100];
  13. ifstream f1;
  14. f1.open("c:\\temp\\Filemas1_3.txt");
  15. f1>>m>>n;
  16. if(n==0)
  17. {n=1;}
  18. if(m==0)
  19. {m=1;}
  20. {for(i=0;i<m;i++)
  21. {for(j=0;j<n;j++)
  22. f1>>A[i][j];
  23. }
  24. }
  25. f1.close();
  26. {for(i=0;i<m;i++)
  27. {for(j=0;j<n;j++)
  28. cout<<setw(2)<<A[i][j]<<" ";
  29. cout<<endl;
  30. }
  31. }
  32. ofstream f2;
  33. f2.open("C:\\temp\\Filemas2_0.txt");
  34. for(int i=0;i<m;i++)
  35. {
  36. for(int j=0;j<n;j++){
  37. f2<<setw(3)<<A[i][j]<<" ";}
  38. f2<<endl;
  39. }
  40. f2.close();
  41. if(m==1)
  42. {
  43. ofstream f3;
  44. f3.open("C:\\temp\\Filemas3_0.txt");
  45. cout<<"\n Функция №2:\n";
  46. {for(i=0;i<m;i++)
  47. {for(j=0;j<n;j++)
  48. cout<<setw(2)<<A[i][j]<<" ";
  49. cout<<endl;
  50. }
  51. }
  52. cout<<"\n Нечетные элементы:\n";
  53. {for(i=0;i<m;i++)
  54. {for(j=0;j<n;j++)
  55. if(A[i][j]%2!=0)
  56. {
  57. cout<<setw(2)<<A[i][j]<<" ";
  58. }
  59. }
  60. }
  61. for(int i=0;i<m;i++)
  62. {
  63. for(int j=0;j<n;j++){
  64. f3<<setw(2)<<A[i][j]<<" ";}
  65. f3<<endl;
  66. }
  67. f3.close();
  68. }
  69. if(n==1)
  70. {
  71. ofstream f4;
  72. f4.open("C:\\temp\\Filemas3_0.txt");
  73. cout<<"\n Функция №2:\n";
  74. for(int i=0;i<m;i++)
  75. {
  76. for(int j=0;j<n;j++)
  77. }
  78. if(A[i][j]%2)=0
  79. {for(i=0;i<m;i++)
  80. {for(j=0;j<n;j++)
  81. cout<<setw(2)<<A[i][j]<<" ";
  82. cout<<endl;
  83. }
  84. }
  85. {for(i=0;i<m;i++)
  86. {for(j=0;j<n;j++)
  87. }
  88. }
  89. if(A[i][j]%2)=0
  90. f4<<setw(2)<<A[i][j]<<" ";
  91. f4.close();
  92. }
  93. if((m!=1)&&(n!=1))
  94. {
  95. ofstream f5;
  96. f5.open("C:\\temp\\Filemas3_0.txt");
  97. cout<<"\n Введите 2 числа:\n";
  98. cin>>a>>b;
  99. if (a<b)
  100. {
  101. c=b;
  102. }
  103. else
  104. c=a;
  105. {for(i=0;i<m;i++)
  106. {for(j=0;j<n;j++)
  107. if(A[i][j]<c)
  108.  
  109. {
  110. A[i][j]= A[i][j]*A[i][j]
  111. }
  112. cout<<setw(2)<<A[i][j]<<" ";
  113. }
  114. }
  115. {for(i=0;i<m;i++)
  116. {for(j=0;j<n;j++)
  117. if(A[i][j]<c)
  118.  
  119. {
  120. A[i][j]= A[i][j]*A[i][j]
  121. }
  122. f5<<setw(2)<<A[i][j]<<" ";
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement