fork(2) download
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. int compare (const void * a, const void * b);
  7.  
  8.  
  9. int main()
  10. {
  11. ios_base::sync_with_stdio(0);
  12.  
  13. int tablica[10], wyjscie[5] = {0, 0, 0, 0, 0}, suma = 0;
  14.  
  15. for(int i = 0; i<10; i++)
  16. {
  17. cin>>tablica[i];
  18. suma+=tablica[i];
  19. }
  20. qsort(tablica,10,sizeof(int),compare);
  21. wyjscie[2]=suma/20;
  22. /*while(tablica[1]-wyjscie[3]!=wyjscie[1])wyjscie[1]+=1;
  23.   while(tablica[0]-wyjscie[1]!=wyjscie[2])wyjscie[2]+=1;
  24.   while(tablica[8]-wyjscie[3]!=wyjscie[5])wyjscie[5]+=1;
  25.   while(tablica[9]-wyjscie[5]!=wyjscie[4])wyjscie[4]+=1;*/
  26. wyjscie[0]=tablica[1]-wyjscie[2];
  27. wyjscie[1]=tablica[0]-wyjscie[0];
  28. wyjscie[4]=tablica[8]-wyjscie[2];
  29. wyjscie[3]=tablica[9]-wyjscie[4];
  30. for(int wypisz = 0; wypisz<5; wypisz++)cout<<wyjscie[wypisz]<<"\n";
  31. cout<<"wypisalem juz wyjscie, teraz debug\n";
  32. for(int debug = 0; debug<10; debug++)cout<<tablica[debug]<<"\n|";
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. return 0;
  40. }
  41.  
  42.  
  43. int compare (const void * a, const void * b)
  44. {
  45. return ( *(int*)a - *(int*)b );
  46. }
  47.  
  48.  
Success #stdin #stdout 0s 2988KB
stdin
10 12 16 10 6 12 18 8 14 14
stdout
2
4
6
8
10
wypisalem juz wyjscie, teraz debug
6
|8
|10
|10
|12
|12
|14
|14
|16
|18
|