RSS Forums RSS
Please support our C++ advertiser: Programming Forums

min value

Join Date: Nov 2006
Location: Athens, Greece
Posts: 201
Reputation: n.aggel is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 9
n.aggel's Avatar
n.aggel n.aggel is offline Offline
Posting Whiz in Training

Re: min value

  #2  
Nov 6th, 2007
please use code tags or other people won't be able to help you....

here is your code


  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <ctime>
  7. using namespace std;
  8.  
  9. int i;
  10. int x[7];
  11. int A[7], B[7], C[7], D[7], E[7], F[7];
  12. int Min( const int *A, const int Count);
  13. int minimum, minA, minB, flagB;
  14. int main(void);
  15. int count = 7;
  16. {
  17. for(i=1;i<7;i++)
  18. {
  19. x[i]=i;
  20. A[i]=(2+pow(x[i],2));
  21. B[i]=(1+pow(x[i],3));
  22. C[i]=(2+pow(x[i],2)-1);
  23. D[i]=(3*pow(x[i],3));
  24. E[i]=(1+pow(x[i],2));
  25. F[i]=(3+pow(x[i],2));
  26. }
  27. {
  28. cout <<"\n";
  29.  
  30. for(i=1;i<7; i++)
  31. { printf("[%d][%d] A[%d]=%d\n", i,1, i, A[i]);
  32. }
  33. cout <<"\n";
  34. for(i=1;i<7; i++)
  35. {
  36. printf("[%d][%d] B[%d]=%d\n", i,2, i, B[i]);
  37. }
  38. cout <<"\n";
  39. for(i=1;i<7; i++)
  40. {
  41. printf("[%d][%d] C[%d]=%d\n", i,3, i, C[i]);
  42. }
  43. cout <<"\n";
  44. for(i=1;i<7; i++)
  45. {
  46. printf("[%d][%d] D[%d]=%d\n", i,4, i, D[i]);
  47.  
  48. }
  49. cout <<"\n";
  50. for(i=1;i<7; i++)
  51. {
  52. printf("[%d][%d] E[%d]=%d\n", i,5, i, E[i]);
  53. }
  54. cout <<"\n";
  55. for(i=1;i<7; i++)
  56. {
  57. printf("[%d][%d] F[%d]=%d\n", i,6, i, F[i]);
  58. }
  59. }
  60. printf("\n");
  61. printf ("A\tB\tC\tD\tE\tF");
  62. printf ("\n_\t_\t_\t_\t_\t_\t");
  63. for(i=1;i<7;i++)
  64. {
  65. cout<<endl;
  66. printf("%d\t", A[i]);
  67. printf("%d\t", B[i]);
  68. printf("%d\t", C[i]);
  69. printf("%d\t", D[i]);
  70. printf("%d\t", E[i]);
  71. printf("%d\t", F[i]);
  72. }
  73. cout <<"\n";
  74. // Compare the members
  75. int Minimum = A[0];
  76. for (int i=1; i<7; i++)
  77. if (minimum > A[i]) Minimum = A[i];
  78. return minimum;
  79. }
  80.  
  81. // Announce the result
  82. cout << "The minimum value of the array A is "<< A[minA] << "." << endl;
  83. }
  84. }

what compiler do you use? on gcc it doesn't compile....

remove line 2:: #include <conio.h>

also in lines like A[i]=(2+pow(x[i],2)); you must cast the operands to double, so that there is no amguity as to which overloaded function of pow the compiler selects..

to do this type:: A[i]=( 2+pow( static_cast<double>(x[i]),static_cast<double>(2) ) );
Two roads diverged in a wood, and I— I took the one less traveled by, and that has made all the difference.

by Robert Frost the "The Road Not Taken"
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:10 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC