#include <stdio.h>
int countCntyOccur ( char cntyCodes[ ] , int size) ;
int main( void ) {
char cntyCodes[ ] = { 'C' , 'c' , 'c' , 'D' , 'd' , 'G' , 'L' , 'l' , 'l' , 'L' , 'T' , 't' , 't' , 'W' , 'w' , 'X' } ;
countCntyOccur( cntyCodes, 14 ) ;
return 0 ;
}
int countCntyOccur ( char cntyCodes[ ] , int size) {
int totalCorkCodes= 0 ;
int totalDublinCodes= 0 ;
int totalGalwayCodes= 0 ;
int totalLimerickCodes= 0 ;
int totalTiperaryCodes= 0 ;
int totalWaterfordCodes= 0 ;
int totalInvalidCountyCodes= 0 ;
for ( int i = 0 ; i < size; i++ ) {
// Switch statement
switch ( cntyCodes[ i] ) {
case 'C' :
case 'c' :
totalCorkCodes+= 1 ;
break ;
case 'D' :
case 'd' :
totalDublinCodes+= 1 ;
break ;
case 'G' :
case 'g' :
totalGalwayCodes+= 1 ;
break ;
case 'L' :
case 'l' :
totalLimerickCodes+= 1 ;
break ;
case 'T' :
case 't' :
totalTiperaryCodes+= 1 ;
break ;
case 'W' :
case 'w' :
totalWaterfordCodes+= 1 ;
break ;
default :
totalInvalidCountyCodes+= 1 ;
}
}
printf ( "The number of Cork codes is: %i\n " , totalCorkCodes
) ; printf ( "The number of Dublin codes is: %i\n " , totalDublinCodes
) ; printf ( "The number of Galway codes is: %i\n " , totalGalwayCodes
) ; printf ( "The number of Limerick codes is: %i\n " , totalLimerickCodes
) ; printf ( "The number of Waterford codes is: %i\n " , totalWaterfordCodes
) ; printf ( "The number of invalud codes is: %i\n " , totalInvalidCountyCodes
) ; // struct countryTotals{
// int totalCorkCodes;
// int totalDublinCodes;
// int totalGalwayCodes;
// int totalLimerickCodes;
// int totalTiperaryCodes;
// int totalWaterfordCodes;
// int totalInvalidCountryCodes;
// }
// return countryTotals;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgY291bnRDbnR5T2NjdXIgKGNoYXIgY250eUNvZGVzW10saW50IHNpemUpOwoKaW50IG1haW4odm9pZCkgewoJY2hhciBjbnR5Q29kZXNbXT0geydDJywnYycsJ2MnLCdEJywnZCcsJ0cnLCdMJywnbCcsJ2wnLCdMJywnVCcsJ3QnLCd0JywnVycsJ3cnLCdYJ307CiAgICBjb3VudENudHlPY2N1cihjbnR5Q29kZXMsMTQpOwoJcmV0dXJuIDA7Cn0KCgppbnQgY291bnRDbnR5T2NjdXIgKGNoYXIgY250eUNvZGVzW10saW50IHNpemUpewoKICAgIGludCB0b3RhbENvcmtDb2Rlcz0wOwogICAgaW50IHRvdGFsRHVibGluQ29kZXM9MDsKICAgIGludCB0b3RhbEdhbHdheUNvZGVzPTA7CiAgICBpbnQgdG90YWxMaW1lcmlja0NvZGVzPTA7CiAgICBpbnQgdG90YWxUaXBlcmFyeUNvZGVzPTA7CiAgICBpbnQgdG90YWxXYXRlcmZvcmRDb2Rlcz0wOwogICAgaW50IHRvdGFsSW52YWxpZENvdW50eUNvZGVzPTA7CgoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgc2l6ZTsgaSsrKSB7CiAgICAgICAgLy8gU3dpdGNoIHN0YXRlbWVudAogICAgICAgIHN3aXRjaCAoY250eUNvZGVzW2ldKSB7CiAgICAgICAgY2FzZSAnQyc6CiAgICAgICAgY2FzZSAnYyc6CiAgICAgICAgICAgIHRvdGFsQ29ya0NvZGVzKz0xOwogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAnRCc6CiAgICAgICAgY2FzZSAnZCc6CiAgICAgICAgICAgIHRvdGFsRHVibGluQ29kZXMrPTE7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdHJzoKICAgICAgICBjYXNlICdnJzoKICAgICAgICAgICAgdG90YWxHYWx3YXlDb2Rlcys9MTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ0wnOgogICAgICAgIGNhc2UgJ2wnOgogICAgICAgICAgICB0b3RhbExpbWVyaWNrQ29kZXMrPTE7CiAgICAgICAgICAgIGJyZWF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