Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int v[11];
- int contor;
- char nr;
- int C;
- int valmax;
- int main(){
- ofstream g("bucati.out");
- ifstream f("bucati.in");
- f>>C;
- while(f>>nr){
- v[++contor]=nr-'0';
- if(v[contor]>valmax)
- valmax=v[contor];
- }
- f.close();
- if(C==1){
- if(valmax!=v[1]){
- while(valmax!=v[1]){
- int aux=v[contor];
- for(int j=contor-1; j>=1; j--){
- v[j+1]=v[j];
- }
- v[1]=aux;
- }
- }else{
- while(v[1]==v[contor]){
- int aux=v[contor];
- for(int j=contor-1; j>=1; j--){
- v[j+1]=v[j];
- }
- v[1]=aux;
- }
- }
- int num=0;
- for(int i=1; i<=contor-2; i++)
- num=num*10+v[i];
- for(int i=contor-1; i<=contor; i++)
- num+=v[i];
- g<<num;
- }else{
- int p1=v[1];
- int p2=v[contor];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement