Edit: Re-do the answer as the IP's in the question changed.
Note1: It is WRONG to route different subnet masks in the same network/vlan this is just a explanations as to why it work's in certain cases for certain specific IP's.
Note2: Even if the subnets provided were in different vlans, it would be a Broken configuration as the subnet's overlap
IP routing on a host is configured with three pieces of information.
- IP Address
The Mask splits the IP into a upper and lower half (In binary format). The first half (where the mask is all ones) is the network and the second half is the host.
All IP's in the same network IP/mask can talk to each other directly, if the network portion does not match the Gateway is used to router the packets.
A: 184.108.40.206/24 (255.255.255.0)
Network 220.127.116.11 Host 0.0.0.1 (HostRange 0.0.0.1-0.0.0.254)
IpRange 18.104.22.168 - 22.214.171.124 (Excluding network and broadcast)
B: 126.96.36.199/22 (255.255.252.0)
Network 188.8.131.52 Host 0.0.1.2 (HostRange 0.0.0.1-0.0.3.254)
IpRange 184.108.40.206 - 220.127.116.11 (Excluding network and broadcast)
C: 18.104.22.168/21 (255.255.248.0)
Network 22.214.171.124 Host 0.0.1.3 (HostRange 0.0.0.1-0.0.7.254)
IpRange 126.96.36.199 - 188.8.131.52 (Excluding network and broadcast)
The mask is a binary mask, all ones and then all zeros, total length for IPv4 is 8x4=32 bit.
Answer: If you have a host1 talking to a Host2 and according to host 1, host 2 is in the same Network(IP/mask) it will send packets directly.
In the provided example, although misconfiguration the Network portion of ip A, B and C matches.
This would break down if i chose in the same subnets different IP's, they would not be able to ping each other with out the assistance of a L3/Router to route between the subnets.