Advertisement
alexon5519

13-programare

Dec 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main(){
  8. ifstream f1("atestat.in");
  9. ofstream f2("atestat.out");
  10. int n, x, y, r, i, j, c=0, a[50], b[100], d[50], m=0, p=0, schimb; //m-contor pentru raza a[50]
  11. f1>>n; //p-contop pentru elementele razei b[100]
  12. while(f1>>x>>y>>r){
  13. if(x==y)
  14. c++;
  15. p++;
  16. b[p]=x;
  17. p++;
  18. b[p]=y;
  19. m++;
  20. a[m]=r;
  21. d[m]=r;
  22. }
  23. for(i=1;i<=m-1;i++){
  24. for(j=i+1;j<=m;j++)
  25. if(a[i]>a[j]){
  26. schimb=a[i];
  27. a[i]=a[j];
  28. a[j]=schimb;
  29. }
  30. }
  31. for(i=1;i<=m;i++)
  32. for(j=1;j<=m;j++)
  33. if(a[i]==d[j]){
  34. f2<<b[2*j-1]<<" "<<b[2*j]<<" "<<d[j]<<endl;
  35. }
  36. f2<<c;
  37. f2.close();
  38. f1.close();
  39. }
  40. #include<iostream>
  41. #include<fstream>
  42.  
  43. using namespace std;
  44.  
  45.  
  46. int main(){
  47. ifstream f1("atestat.in");
  48. ofstream f2("atestat.out");
  49. int n, x, y, r, i, j, c=0, a[50], b[100], d[50], m=0, p=0, schimb; //m-contor pentru raza a[50]
  50. f1>>n; //p-contop pentru elementele razei b[100]
  51. while(f1>>x>>y>>r){
  52. if(x==y)
  53. c++;
  54. p++;
  55. b[p]=x;
  56. p++;
  57. b[p]=y;
  58. m++;
  59. a[m]=r;
  60. d[m]=r;
  61. }
  62. for(i=1;i<=m-1;i++){
  63. for(j=i+1;j<=m;j++)
  64. if(a[i]>a[j]){
  65. schimb=a[i];
  66. a[i]=a[j];
  67. a[j]=schimb;
  68. }
  69. }
  70. for(i=1;i<=m;i++)
  71. for(j=1;j<=m;j++)
  72. if(a[i]==d[j]){
  73. f2<<b[2*j-1]<<" "<<b[2*j]<<" "<<d[j]<<endl;
  74. }
  75. f2<<c;
  76. f2.close();
  77. f1.close();
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement