Advertisement
crisfast

23/10/2014

Oct 23rd, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. // minimapelinie.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9. int a[10][10],m,n,min,i,j,k,v[100],minl,h=0;
  10. printf("Numar linii:");
  11. scanf("%d",&m);
  12. printf("Numar coloane:");
  13. scanf("%d",&n);
  14. for(i=0;i<=m-1;i++)
  15. for(j=0;j<=n-1;j++)
  16. { printf("a[%d][%d]=",i,j);
  17. scanf("%d",&a[i][j]);
  18. }
  19. printf("Matricea este: \n");
  20. for(i=0;i<=m-1;i++)
  21. {for(j=0;j<=n-1;j++)
  22. printf("%d ",a[i][j]);
  23. printf("\n");}
  24. for(i=0;i<=m-1;i++)
  25. {minl=9999;
  26. for(j=0;j<=n-1;j++)
  27. if(a[i][j]<minl) v[++h]=a[i][j]
  28.  
  29.  
  30. scanf("%d",&k);
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37. // ma_pozitive_negative.cpp : Defines the entry point for the console application.
  38. //
  39.  
  40. #include "stdafx.h"
  41.  
  42.  
  43. int _tmain(int argc, _TCHAR* argv[])
  44. {
  45. int i,v[100],n,cn,cp,sp,sn,k;
  46. float mp,mn;
  47. cn=0;
  48. cp=0;
  49. sn=0;
  50. sp=0;
  51. printf("Numar de elemente din vector:");
  52. scanf("%d",&n);
  53. for(i=0;i<n;i++)
  54. {printf("Introduceti numar:");
  55. scanf("%f",&v[i]);}
  56. for(i=0;i<=n-1;i++)
  57. if(v[i]<0) {cn=cn+1;
  58. sn=sn+l;}
  59. else {cp=cp+1;
  60. sp=sp+v[i];}
  61.  
  62. mp=sp/cp;
  63. printf("%f %d %d",mp,sp,cp);
  64. /*
  65. mn=sn/cn;
  66. printf("%f",mn);
  67. /*
  68. if(cp==0) printf("Nu exista numere pozitive!\n");
  69. else {mp=(float)sp/cp;
  70. printf("%f",mp);
  71. printf("\n");
  72. }
  73. if(cn==0) printf("Nu exista numere negative!\n");
  74. else {mn=(float)sn/cn;
  75. printf("%f",mn);
  76. printf("\n");
  77. }*/
  78. scanf("%d",&k);
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement