fork(1) download
  1.  
  2. #include <iostream>
  3. #include <math.h>
  4. #include <time.h>
  5. #include<iomanip>
  6. #include<array>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10. const int AS = 6;
  11. void FillingRandomly(int (*)[AS]);
  12. void printing(int (*)[AS]);
  13. void forsorting(int(*)[AS], int);
  14. void swap(int * const, int * const);
  15. int c;
  16.  
  17. int main()
  18.  
  19. {
  20. int funny = 0;
  21. int timpa = 0;
  22. int counter = 0;
  23. int Array[AS][AS];
  24. srand(time(0));
  25.  
  26.  
  27. FillingRandomly(Array);
  28.  
  29.  
  30. cout << "The unsorted array is" << endl << endl;
  31.  
  32. printing(Array);
  33.  
  34.  
  35. cout << "The sorted array is" << endl << endl;
  36.  
  37.  
  38.  
  39. forsorting(Array, funny);
  40.  
  41. printing(Array);
  42.  
  43.  
  44.  
  45. system("PAUSE");
  46.  
  47.  
  48. return 0;
  49.  
  50. }
  51.  
  52. void FillingRandomly(int *Array)
  53. {*Array=rand()%87 +12;
  54. *Array++;
  55. }
  56.  
  57.  
  58.  
  59. void printing(int *ArrayPtr)
  60. {
  61. int counter = 0;
  62. while(*ArrayPtr<AS*AS)
  63. {
  64. cout<<*ArrayPtr;
  65. *ArrayPtr++;
  66. if (*ArrayPtr%AS == 0)
  67. cout << endl << endl;
  68. }
  69. }
  70.  
  71. void forsorting(int *Array[AS][AS], int funny)
  72. {
  73.  
  74. int w=0;
  75. int dice = 0;
  76. int Brray[AS*AS];
  77. int super = 0;
  78. int space=0;
  79.  
  80.  
  81.  
  82. //Transofrming Array[][] into Brray[]
  83. for (int i = 0; i < AS; i++)
  84. {
  85. for (int k = 0; k < AS; k++)
  86. {
  87. Brray[space] = *Array[k][i];
  88. space++;
  89. }
  90. }
  91.  
  92.  
  93. //Sorting Brray[]
  94.  
  95. {
  96.  
  97. for (int pass = 0; pass < AS*AS - 1; pass++) {
  98.  
  99. for (int k = 0; k < AS*AS - 1; k++) {
  100. int temp;
  101. if ( Array[k] > Array[k + 1] ) {
  102. swap( &Array[k], &Array[k + 1]);
  103. }
  104. }
  105. }
  106. }
  107. void swap(int * const element1Ptr, int * const element2Ptr)
  108. {
  109. int hold = *element1Ptr;
  110. *element1Ptr = *element2Ptr;
  111. *element2Ptr = hold;
  112. }
  113.  
  114. //Transforming Brray[] into sorted Array[][]
  115.  
  116. w=0;
  117. for (int j=0;j<AS;j++) {
  118. for (int i=0;i<AS;i++)
  119. {
  120. *Array[j][i] = Brray[w++];
  121. }
  122.  
  123. }
  124. }
  125.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:21:6: warning: unused variable ‘timpa’ [-Wunused-variable]
  int timpa = 0;
      ^
prog.cpp:22:6: warning: unused variable ‘counter’ [-Wunused-variable]
  int counter = 0;
      ^
prog.cpp: In function ‘void FillingRandomly(int*)’:
prog.cpp:54:9: warning: value computed is not used [-Wunused-value]
 *Array++;
         ^
prog.cpp: In function ‘void printing(int*)’:
prog.cpp:65:15: warning: value computed is not used [-Wunused-value]
    *ArrayPtr++;
               ^
prog.cpp:61:6: warning: unused variable ‘counter’ [-Wunused-variable]
  int counter = 0;
      ^
prog.cpp: In function ‘void forsorting(int* (*)[6], int)’:
prog.cpp:102:47: error: no matching function for call to ‘swap(int* (*)[6], int* (*)[6])’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
prog.cpp:102:47: note: candidates are:
prog.cpp:14:6: note: void swap(int*, int*)
 void swap(int * const, int * const);  
      ^
prog.cpp:14:6: note:   no known conversion for argument 1 from ‘int* (*)[6]’ to ‘int*’
In file included from /usr/include/c++/4.8/bits/stl_algo.h:66:0,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:7:
/usr/include/c++/4.8/functional:2570:5: note: template<class _Res, class ... _Args> void std::swap(std::function<_Res(_ArgTypes ...)>&, std::function<_Res(_ArgTypes ...)>&)
     swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y)
     ^
/usr/include/c++/4.8/functional:2570:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::function<_Res(_ArgTypes ...)>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/functional:55:0,
                 from /usr/include/c++/4.8/bits/stl_algo.h:66,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:7:
/usr/include/c++/4.8/tuple:1048:5: note: template<class ... _Elements> void std::swap(std::tuple<_Elements ...>&, std::tuple<_Elements ...>&)
     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
     ^
/usr/include/c++/4.8/tuple:1048:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::tuple<_Elements ...>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/vector:65:0,
                 from /usr/include/c++/4.8/bits/random.h:34,
                 from /usr/include/c++/4.8/random:50,
                 from /usr/include/c++/4.8/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:7:
/usr/include/c++/4.8/bits/stl_bvector.h:128:3: note: void std::swap(bool&, std::_Bit_reference)
   swap(bool& __x, _Bit_reference __y) noexcept
   ^
/usr/include/c++/4.8/bits/stl_bvector.h:128:3: note:   no known conversion for argument 1 from ‘int* (*)[6]’ to ‘bool&’
/usr/include/c++/4.8/bits/stl_bvector.h:120:3: note: void std::swap(std::_Bit_reference, bool&)
   swap(_Bit_reference __x, bool& __y) noexcept
   ^
/usr/include/c++/4.8/bits/stl_bvector.h:120:3: note:   no known conversion for argument 1 from ‘int* (*)[6]’ to ‘std::_Bit_reference’
/usr/include/c++/4.8/bits/stl_bvector.h:112:3: note: void std::swap(std::_Bit_reference, std::_Bit_reference)
   swap(_Bit_reference __x, _Bit_reference __y) noexcept
   ^
/usr/include/c++/4.8/bits/stl_bvector.h:112:3: note:   no known conversion for argument 1 from ‘int* (*)[6]’ to ‘std::_Bit_reference’
In file included from /usr/include/c++/4.8/vector:64:0,
                 from /usr/include/c++/4.8/bits/random.h:34,
                 from /usr/include/c++/4.8/random:50,
                 from /usr/include/c++/4.8/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8/algorithm:62,
                 from prog.cpp:7:
/usr/include/c++/4.8/bits/stl_vector.h:1451:5: note: template<class _Tp, class _Alloc> void std::swap(std::vector<_Tp, _Alloc>&, std::vector<_Tp, _Alloc>&)
     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
     ^
/usr/include/c++/4.8/bits/stl_vector.h:1451:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::vector<_Tp, _Alloc>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from prog.cpp:6:0:
/usr/include/c++/4.8/array:262:5: note: template<class _Tp, unsigned int _Nm> void std::swap(std::array<_Tp, _Nm>&, std::array<_Tp, _Nm>&)
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
     ^
/usr/include/c++/4.8/array:262:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::array<_Tp, _Nm>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/basic_string.h:2717:5: note: template<class _CharT, class _Traits, class _Alloc> void std::swap(std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&)
     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2717:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::basic_string<_CharT, _Traits, _Alloc>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/stl_pair.h:254:5: note: template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)
     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
     ^
/usr/include/c++/4.8/bits/stl_pair.h:254:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘std::pair<_T1, _T2>’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/move.h:185:5: note: template<class _Tp, unsigned int _Nm> void std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
     ^
/usr/include/c++/4.8/bits/move.h:185:5: note:   template argument deduction/substitution failed:
prog.cpp:102:47: note:   mismatched types ‘_Tp [_Nm]’ and ‘int* (*)[6]’
                 swap( &Array[k], &Array[k + 1]);
                                               ^
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:2:
/usr/include/c++/4.8/bits/move.h:166:5: note: void std::swap(_Tp&, _Tp&) [with _Tp = int* (*)[6]]
     swap(_Tp& __a, _Tp& __b)
     ^
/usr/include/c++/4.8/bits/move.h:166:5: note:   no known conversion for argument 1 from ‘int* (*)[6]’ to ‘int* (*&)[6]’
prog.cpp:100:17: warning: unused variable ‘temp’ [-Wunused-variable]
             int temp;
                 ^
prog.cpp:108:5: error: a function-definition is not allowed here before ‘{’ token
     {
     ^
prog.cpp:75:6: warning: unused variable ‘dice’ [-Wunused-variable]
  int dice = 0;
      ^
prog.cpp:77:6: warning: unused variable ‘super’ [-Wunused-variable]
  int super = 0;
      ^
stdout
Standard output is empty