Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. setlocale (LC_ALL,"Russian");
  10. float **a;
  11. int summ_poz=0;
  12.  
  13. a=new float*[9];
  14. for(int i=0;i<9;i++)
  15. {
  16. a[i]=new float[4];
  17. for(int j=0;j<4;j++)
  18. {
  19. a[i][j]=0.1*(rand()%121-80);
  20. cout<<fixed<<" "<<setprecision(1)<<a[i][j]<<" ";
  21. }
  22. cout<<endl;
  23. }
  24.  
  25. for(int i=0;i<9;i++)
  26. {
  27. for(int j=0;j<4;j++)
  28. {
  29. if(a[i][j]>0)
  30. {
  31. summ_poz++;
  32. }
  33. if(i==j)
  34. {
  35. a[i][j]=1;
  36. }
  37. }
  38. }
  39.  
  40. cout<<endl;
  41. cout<<endl;
  42. cout<<endl;
  43. for(int i=0;i<9;i++)
  44. {
  45. for(int j=0;j<4;j++)
  46. {
  47. cout<<fixed<<" "<<setprecision(1)<<a[i][j]<<" ";
  48. }
  49. cout<<endl;
  50. }
  51.  
  52. cout<<"Сумма положительных элементов "<<summ_poz<<endl;
  53. system ("pause");
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement