#include <iostream>
using namespace std;
int modify(int l, int k){
return l*10+k;
}
int main()
{
int n;
int ost=0;
int li, temp;
int counter=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>li;
while (li<ost){
for(int j=0;j<10;j++){
temp=modify(li,j);
if(temp>ost){
li=temp;
counter++;
break;
}
}
if(li<ost){
li=modify(li,0);
counter++;
}
}
ost=li;
}
cout<<counter;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> using namespace std; int modify(int l, int k){ return l*10+k; } int main() { int n; int ost=0; int li, temp; int counter=0; cin>>n; for(int i=0;i<n;i++){ cin>>li; while (li<ost){ for(int j=0;j<10;j++){ temp=modify(li,j); if(temp>ost){ li=temp; counter++; break; } } if(li<ost){ li=modify(li,0); counter++; } } ost=li; } cout<<counter; return 0; } |
English