Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int main(){
- ifstream f1("atestat.in");
- ofstream f2("atestat.out");
- 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]
- f1>>n; //p-contop pentru elementele razei b[100]
- while(f1>>x>>y>>r){
- if(x==y)
- c++;
- p++;
- b[p]=x;
- p++;
- b[p]=y;
- m++;
- a[m]=r;
- d[m]=r;
- }
- for(i=1;i<=m-1;i++){
- for(j=i+1;j<=m;j++)
- if(a[i]>a[j]){
- schimb=a[i];
- a[i]=a[j];
- a[j]=schimb;
- }
- }
- for(i=1;i<=m;i++)
- for(j=1;j<=m;j++)
- if(a[i]==d[j]){
- f2<<b[2*j-1]<<" "<<b[2*j]<<" "<<d[j]<<endl;
- }
- f2<<c;
- f2.close();
- f1.close();
- }
- #include<iostream>
- #include<fstream>
- using namespace std;
- int main(){
- ifstream f1("atestat.in");
- ofstream f2("atestat.out");
- 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]
- f1>>n; //p-contop pentru elementele razei b[100]
- while(f1>>x>>y>>r){
- if(x==y)
- c++;
- p++;
- b[p]=x;
- p++;
- b[p]=y;
- m++;
- a[m]=r;
- d[m]=r;
- }
- for(i=1;i<=m-1;i++){
- for(j=i+1;j<=m;j++)
- if(a[i]>a[j]){
- schimb=a[i];
- a[i]=a[j];
- a[j]=schimb;
- }
- }
- for(i=1;i<=m;i++)
- for(j=1;j<=m;j++)
- if(a[i]==d[j]){
- f2<<b[2*j-1]<<" "<<b[2*j]<<" "<<d[j]<<endl;
- }
- f2<<c;
- f2.close();
- f1.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement