Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int v[11];
  7. int contor;
  8. char nr;
  9. int C;
  10. int valmax;
  11.  
  12. int main(){
  13.  
  14. ofstream g("bucati.out");
  15. ifstream f("bucati.in");
  16. f>>C;
  17. while(f>>nr){
  18. v[++contor]=nr-'0';
  19. if(v[contor]>valmax)
  20. valmax=v[contor];
  21. }
  22. f.close();
  23.  
  24. if(C==1){
  25. if(valmax!=v[1]){
  26. while(valmax!=v[1]){
  27. int aux=v[contor];
  28. for(int j=contor-1; j>=1; j--){
  29. v[j+1]=v[j];
  30. }
  31. v[1]=aux;
  32. }
  33. }else{
  34. while(v[1]==v[contor]){
  35. int aux=v[contor];
  36. for(int j=contor-1; j>=1; j--){
  37. v[j+1]=v[j];
  38. }
  39. v[1]=aux;
  40. }
  41. }
  42. int num=0;
  43. for(int i=1; i<=contor-2; i++)
  44. num=num*10+v[i];
  45. for(int i=contor-1; i<=contor; i++)
  46. num+=v[i];
  47. g<<num;
  48. }else{
  49. int p1=v[1];
  50. int p2=v[contor];
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement