Interesting idea. I've made fast research of resources about stock of ammunition on u-boots and find this info:
Type VII
8,8 cm/45 SK C/35 gun - 250 rounds of ammunition (220 according to
www.navweaps.com)
2 cm/65 C/30 & C/38 flak - 4380 rounds
Type IX
10,5 cm/45 SK C/32 gun - 180 rounds (or 110 on IX A-C and 150 on IXD according to uboat.net and
www.navweaps.com infos)
3,7 cm/83 SK C/30 & 3,7 cm/69 M42 flak - 2625 rounds
2 cm - 4250 - 8500 rounds