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: 220.127.116.11/24 (255.255.255.0)
Network 18.104.22.168 Host 0.0.0.1 (HostRange 0.0.0.1-0.0.0.254)
IpRange 22.214.171.124 - 126.96.36.199 (Excluding network and broadcast)
B: 188.8.131.52/22 (255.255.252.0)
Network 184.108.40.206 Host 0.0.1.2 (HostRange 0.0.0.1-0.0.3.254)
IpRange 220.127.116.11 - 18.104.22.168 (Excluding network and broadcast)
C: 22.214.171.124/21 (255.255.248.0)
Network 126.96.36.199 Host 0.0.1.3 (HostRange 0.0.0.1-0.0.7.254)
IpRange 188.8.131.52 - 184.108.40.206 (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.