unsigned howMany(char c, const char * s){ static unsigned retVal; //Must remember to use static var if (*s){ if (*s == c) retVal++; howMany(c, (s + 1)); } return retVal; }
int main() { int N, M, i, j, b; scanf("%d", &N); for ( i = 1; i <= N; i++ ) { scanf("%d%d", &j, &M); printf("%d %d\n", i, howMany(M)); } return 0; }
int main() { double a, b, c; unsigned d[] = {1, 22, 3, 44, 5, 1}; double e[] = {1.1, 2.2, 3.3}; char* s = "Jack and Jill."; printf("%lf\n", boxArea(3, 3, 3)); stats(&a, &b, &c, 7, 2, 3); printf("%lf %lf %lf\n", a, b, c); printf("%lf\n", aveOdd(d, 6)); reverse(e, e + 3); printf("%lf %lf %lf\n", e[0], e[1], e[2]); printf("%u\n", howMany('J', s)); return 0; }
void howMany(int nowth){ static int line[8] = {0}; int i,j; if(nowth == 8){ ans++; return; } for(i = 0; i < 8; i++){ int ok = 1; line[nowth] = i; for(j = 0; j < nowth; j++){ if(line[j] == line[nowth] || j - line[j] == nowth - line[nowth] || j + line[j] == nowth + line[nowth]){ ok = 0; break; } } if(ok == 1){ howMany(nowth +1); } } }
int main(){ howMany(0); printf("%d\n", ans); }