Advertisement
alexon5519

20-programare

Feb 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 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 x,y,ok,nr=0,i=0,v[100],a,b[9],j;
  11. while(f1>>x){
  12. i++;
  13. v[i]=x;
  14. y=x;
  15. ok=0;
  16. while(y != 0 && ok == 0){
  17. if(y % 10 == 0){
  18. nr++;
  19. ok=1;
  20. }
  21. y=y/10;
  22. }
  23. }
  24. f2<<nr<<endl;
  25. x=v[1];
  26. ok=0;
  27. for(j=2;j<=i && ok == 0;j++){
  28. a=1;
  29. while(x != 0 && ok == 0 ){
  30. b[a]=x;
  31. if(b[a] == v[j]){
  32. ok=1;
  33. f2<<b[1]<<" "<<v[j];
  34. }
  35. a++;
  36. x=x/10;
  37. }
  38. x=v[j];
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement