Advertisement
Guest User

prgrafuri

a guest
Jan 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <cstdio>
  2. #include <fstream>
  3. using namespace std;
  4. int n,a[101][101],x,y,i,j,maxx,m,nr;
  5. FILE*f=fopen("gradmax.in","r");
  6. FILE*g=fopen("gradmax.out","w");
  7. int main()
  8. {
  9. int s=0;
  10. fscanf(f,"%d",&n); //cin>>n;
  11. while(!feof(f))
  12. {
  13. fscanf(f,"%d",&x);
  14. fscanf(f,"%d",&y);
  15. a[x][y]=a[y][x]=1;
  16. }
  17. for(i=1; i<=n; i++)
  18. {
  19. s=0;
  20. for(j=1; j<=n; j++)
  21. s=s+a[i][j];
  22. a[i][0]=s;
  23. }
  24.  
  25. for(i=1; i<=n; i++)
  26. {
  27. if(a[i][0]>maxx)
  28. {
  29. maxx=a[i][0];
  30. nr=1;
  31. }
  32. else if(maxx==a[i][0])
  33. nr++;
  34. }
  35.  
  36. fprintf(g,"%d ",nr);
  37. for(i=1; i<=n; i++)
  38. {
  39. if(a[i][0]==maxx)
  40. fprintf(g,"%d ",i);
  41. }
  42.  
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement