I have a some problem that is confuse me. I have a lot of if else statemenent in my code, and I want to avoid those if-else statement and do in a way that is easiest. I tried switch, but doesn't work because I should get the month in the output and have no idea. Any suggesten ??
if('j' == c1)
if('a' == c2)
mnth = 1;
else
if ('u' == c2)
if('n' == c3)
mnth = 6;
else if ('l' == c3)
mnth = 7;
else error(c1, c2, c3);
else error(c1, c2, c3);
else
if('f' == c1)
if('e' == c2)
if('b' == c3)
mnth = 2;
else error(c1, c2, c3);
else error(c1, c2, c3);
else
if('m' == c1)
if('a' == c2)
if('y' == c3)
mnth = 5;
else
if('r' == c3)
mnth = 3;
else error(c1, c2, c3);
else error(c1,c2,c3);
else
if('a' == c1)
if('p' == c2)
if('r' == c3)
mnth = 4;
else error(c1, c2, c3 );
else
if('u' == c2)
if('g' == c3)
mnth = 8;
else error(c1,c2,c3);
else error(c1,c2,c3);
else
if('s' == c1)
if('e' == c2)
if('p' == c3)
mnth = 9;
else error(c1, c2, c3);
else error(c1, c2, c3);
else
if('o' == c1)
if('c' == c2)
if('t' == c3)
mnth = 10;
else error(c1, c2, c3);
else error(c1, c2, c3);
else
if('n' == c1)
if('o' == c2)
if('v' == c3)
mnth = 11;
else error(c1, c2, c3);
else error(c1, c2, c3);
else
if('d' == c1)
if('e' == c2)
if('c' == c3)
mnth = 12;
else error(c1, c2, c3);
else error(c1, c2, c3);
else error(c1, c2, c3);
Aucun commentaire:
Enregistrer un commentaire