更小的数
题目描述
https://www.dotcpp.com/oj/problem3143.html
代码
#include<iostream>
using namespace std;
bool isfan(string& nums, int j, int i){
while(i < j){
if(nums[i] > nums[j]){
return true ;
}else if(nums[i] < nums [j]){
return false ;
}
i++;
j--;
}
return false ;
}
int getanswer(string& nums, int size){
int result = 0;
for(int i = 0; i < size; i++){
for(int j = 0; j < i; j++){
if(isfan(nums, i ,j)){
result++ ;
}
}
}
return result;
}
int main(){
string nums;
cin>>nums;
cout << getanswer(nums, nums.size());
return 0;
}

浙公网安备 33010602011771号