Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1.  
  2. -------------------------------------------------------637--------------------------------------------------
  3. #include <iostream>
  4. #include <fstream>
  5. using namespace std;
  6. int n,t[21],v[21];
  7. ifstream f("date.in");
  8.  
  9. void citire()
  10. {
  11. int i;
  12. f>>n;
  13. for(i=1;i<=n;i++)
  14. {f>>t[i];
  15. v[t[i]]++;}
  16. }
  17. void frunze()
  18. {
  19. int i;
  20. for(i=1;i<=n;i++)
  21. if(t[i]==0)
  22. cout<<i<<" radacina"<<endl;
  23. int nr=0;
  24. for(i=1;i<=n;i++)
  25. if(v[i]==0)
  26. nr++;
  27. cout<<nr;
  28. cout<<endl;
  29. for(i=1;i<=n;i++)
  30. if(v[i]==0)
  31. cout<<i<<" ";
  32.  
  33. }
  34. int main()
  35. {citire();
  36. frunze();
  37.  
  38. return 0;
  39. }
  40.  
  41.  
  42. -----------------------------------------------------------652-------------------------------------------
  43. [21:07, 22.1.2018] +40 720 855 078: #include <iostream>
  44. #include <fstream>
  45. using namespace std;
  46. int n,t[21],v[21],k,x[21];
  47. ifstream f("date.in");
  48.  
  49. void citire()
  50. {
  51. int i;
  52. f>>n;
  53. for(i=1;i<=n;i++)
  54. f>>t[i];
  55. f>>k;
  56. for(i=1;i<=k;i++)
  57. f>>v[i];
  58. }
  59. void fii()
  60. {
  61. int i,j;
  62. for(i=1;i<=n;i++)
  63. {for(j=1;j<=n;j++)
  64. if(t[j]==v[i])
  65. x[i]++;}
  66. for(i=1;i<=k;i++)
  67. {
  68. cout<<x[i]<<" ";
  69. for(j=1;j<=n;j++)
  70. if(t[j]==v[i])
  71. cout<<j<<" ";
  72. cout<<endl;
  73. }
  74.  
  75. }
  76.  
  77. int main()
  78. {citire();
  79. fii();
  80.  
  81. return 0;
  82. }
  83. ```````````````````````````````````````````````````````````````1651``````````````````````````````````````````````````````````
  84. #include <iostream>
  85. #include <fstream>
  86.  
  87. //1651 pbinfo
  88.  
  89. using namespace std;
  90.  
  91. int n,m,a[100][100];
  92. float v[100];
  93.  
  94. void citire()
  95. {
  96. int x,y,i,j,cost;
  97.  
  98. cin>>n>>m;
  99. for(i=1;i<=m;i++)
  100. {
  101. cin>>x>>y>>cost;
  102. a[x][y]=a[y][x]=cost;
  103. }
  104. }
  105.  
  106. void medii()
  107. {
  108. int i,j;
  109.  
  110. for(i=1;i<=n;i++) v[i]=0;
  111.  
  112. for(i=1;i<=n;i++)
  113. {
  114. int nr=0;
  115. for(j=1;j<=n;j++)
  116. {
  117. if(a[i][j]!=0) { v[i]+=a[i][j]; nr++; }
  118. }
  119. v[i]=v[i]/nr;
  120. }
  121.  
  122. float min1=32000; int vf;
  123.  
  124. for(i=1;i<=n;i++)
  125. {
  126. if(min1>v[i]) { min1=v[i]; vf=i; }
  127. }
  128.  
  129.  
  130.  
  131. }
  132.  
  133. int main()
  134. {
  135. citire();
  136. medii();
  137.  
  138. return 0;
  139. }
  140.  
  141. `````````````````````````````````````````````````````````1652````````````````````````````````````````````````````````
  142. #include <iostream>
  143. #include <fstream>
  144.  
  145. using namespace std;
  146.  
  147. int n,m,a[101][101],c[101][101];
  148.  
  149. void citire()
  150. {
  151. int x,y,i,j,cost;
  152.  
  153. cin>>n>>m;
  154. for(i=1;i<=m;i++)
  155. {
  156. cin>>x>>y>>cost;
  157. a[x][y]=cost;
  158. }
  159.  
  160. for(i=1;i<=n;i++)
  161. {
  162. for(j=1;j<=n;j++)
  163. {
  164. if(a[i][j]==0&&i!=j) a[i][j]=32000;
  165. }
  166. }
  167. }
  168.  
  169. void Roy_Floyd()
  170. {
  171. int i,j,k;
  172.  
  173. for(i=1;i<=n;i++)
  174. {
  175. for(j=1;j<=n;j++)
  176. {
  177. c[i][j]=a[i][j];
  178. }
  179. }
  180.  
  181. for(k=1;k<=n;k++)
  182. {
  183. for(i=1;i<=n;i++)
  184. {
  185. for(j=1;j<=n;j++)
  186. {
  187. if(i!=j&&j!=k&&i!=k)
  188. {
  189. if(c[i][j]>c[i][k]+c[k][j])
  190. c[i][j]=c[i][k]+c[k][j];
  191. }
  192. }
  193. }
  194. }
  195.  
  196. int nr=0;
  197. for(i=1;i<=n;i++)
  198. {
  199. for(j=1;j<=n;j++)
  200. if(a[i][j]!=32000&&a[i][j]!=0&&i!=j)
  201. {
  202. if(a[i][j]==c[i][j]) { nr++; }
  203. }
  204. }
  205.  
  206. cout<<nr;
  207.  
  208. }
  209.  
  210. int main()
  211. {
  212. citire();
  213. Roy_Floyd();
  214.  
  215. return 0;
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement