#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,l=0,a,s,d,w;
cin>>n;
a=n;
while(a!=0){
l++;
a=a/10;
}
if(l%2==0){
s=n/pow(10,(l/2)+1);
w=pow(10,(l/2)-1);
d=n%w;
} else{
s=n/pow(10,l/2+1);
w=pow(10,l/2);
d=n%w;
}
cout<<s*(pow(10,(l/2)-1));
}
When I input "12345" it should show "1245", but instead it shows "120". Why does it? The code should eliminate the middle digit for uneven numbers, or two middle digits for even numbers, but the right side of the number (variable d) doesn't show the right thing.