Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. #include <stdio.h>
  2. int pick,i,a,b,j;
  3. int q[100];
  4. double tmp;
  5. double m[50][50];
  6. double z[100];
  7. int n[5][5]=
  8. {
  9. {1,2,3,4,5},
  10. {5,6,7,8,9},
  11. {9,10,11,12,13},
  12. {13,14,15,16,17},
  13. {17,18,19,20,21}
  14. };
  15. int main ()
  16. {
  17. printf("Press 1 if you want to enter your own matrix..\n");
  18. printf("Press 2 if you want to use a predetermined matrix..\n");
  19. scanf("%d",&pick);
  20. if(pick==1)
  21. {
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. else if(pick==2)
  30. {
  31. printf("The predetermined matrix is..\n");
  32. for(i=0;i<5;i++)
  33. {
  34. for(j=0;j<5;j++)
  35. {
  36. printf("[%d]",n[i][j]);
  37. }
  38. printf("\n");
  39. }
  40. printf("Press 1 for the average.. Press 2 for the standard deviation ");
  41. scanf("%d",&pick);
  42. if(pick==1)
  43. {
  44. printf("Press 1 to choose the average per row.. Press 2 for per column ");
  45. scanf("%d",&pick);
  46. if(pick==1)
  47. {
  48. printf("This matrix has 5 rows, which do you want to print? ");
  49. scanf("%d",&pick);
  50. tmp=0;
  51. for(i=0;i<5;i++)
  52. {
  53. tmp=tmp+n[pick-1][i];
  54. }
  55. tmp=tmp*0.2;
  56. printf("%d is the average of row %d",tmp,pick);
  57. }
  58. else if(pick==2)
  59. {
  60. printf("This matrix has 5 columns, which do you want to print? ");
  61. scanf("%d",&pick);
  62. tmp=0;
  63. for(i=0;i<5;i++)
  64. {
  65. tmp=tmp+n[i][pick-1];
  66. }
  67. tmp=tmp*0.2;
  68. printf("%d is the average of column %d",tmp,pick);
  69. }
  70.  
  71.  
  72. **********************************************************************************
  73. }
  74. else if(pick==2)
  75. printf("Press 1 for the standard devation per row.. Press 2 per column ");
  76. scanf("%d",pick);
  77. if(pick==1)
  78. {
  79. printf("This matrix has 5 rows, which do you want to print? ");
  80. scanf("%d",&pick);
  81. tmp=0;
  82. for(i=0;i<5;i++)
  83. {
  84. tmp=tmp+n[pick-1][i];
  85. z[i]=n[pick-1][i];
  86. }
  87. tmp=tmp*0.2;
  88. for(i=0;i<5;i++)
  89. {
  90. z[i]=z[i]-tmp;
  91. q[i]=z[i]*z[i];
  92. }
  93. tmp=0;
  94. for(i=0;i<5;i++)
  95. {
  96. tmp=tmp+q[i];
  97. }
  98. tmp=pow(tmp,0.5);
  99. printf("The standard deviation of the %d row is %d",pick,tmp);
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement