Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. /*
  5. void sortowanie(double *tab, int size, int *indeksy){
  6. for(int i=0; i<size; i++)
  7. for(int j=0; j<size-1; j++)
  8. if(*(tab+j) > *(tab+j+1)){
  9. std::swap(*(tab+j), *(tab+j+1));
  10. std::swap(*(indeksy+j), *(indeksy+j+1));
  11. }
  12. }
  13.  
  14. int main(){
  15. int n;
  16.  
  17. std::cout << "Podaj liczbe odcinkow: ";
  18. std::cin >> n;
  19.  
  20. int tab[n][4];
  21. int indeksy[n];
  22. double dlugosci[n];
  23.  
  24. for(int i=0; i<n; i++){
  25. for(int j=0; j<4; j++)
  26. std::cin >> tab[i][j];
  27.  
  28. *(indeksy+i) = i;
  29. *(dlugosci+i) = sqrt((double)(pow(tab[i][2] - tab[i][0], 2) + pow(tab[i][3] - tab[i][1], 2)));
  30. }
  31.  
  32. sortowanie(dlugosci, sizeof(dlugosci)/sizeof(double), indeksy);
  33.  
  34. for(int i=0; i<n; i++){
  35. for(int j=0; j<4; j++)
  36. std::cout << tab[indeksy[i]][j] << " ";
  37. std::cout << std::endl;
  38. }
  39.  
  40. return 0;
  41. }
  42. */
  43. /*
  44.  
  45. int main(){
  46. char input[100];
  47.  
  48. std::cin.getline(input, sizeof(input));
  49.  
  50. for(int i=0; input[i] != '\0'; i++){
  51. input[0] -= 32;
  52. if ((input[i]) == ' '){
  53. input[i+1] -= 32;
  54. continue;
  55. }
  56. else std::cout << input[i];
  57. }
  58. system("pause");
  59. return 0;
  60. }
  61. */
  62. /** kod ingerujący w zmienne
  63.  
  64. #include <iostream>
  65. #include <sstream>
  66.  
  67. std::ostringstream output (char* input){
  68. std::ostringstream oss;
  69.  
  70. oss.str("");
  71. oss.clear();
  72.  
  73. for(int i=0; *(input+i) != '\0'; i++){
  74. if (*(input+i) == ' '){
  75. *(input+i+1) -= 32;
  76. continue;
  77. }
  78. else oss << *(input+i);
  79. }
  80.  
  81. return oss;
  82. }
  83.  
  84. int main(){
  85. char input[100];
  86.  
  87. std::cin.getline(input, sizeof(input));
  88. std::cout << output(input).str();
  89.  
  90. return 0;
  91. }
  92. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement