Flash floods trapped residents in their homes and washed away dozens of cars in northwest China as torrential rain hit the region.