void main() { int errc = 0; bool in_sentence = false; bool in_word = false; char c; while(scanf("%c",&c) > 0) { if(in_sentence) { if(in_word) { if(iscapital(c)) errc++; if(ispunct(c)) in_word = false; } else { if(isalpha(c)) in_word = true; } if(isstop(c)) in_sentence = false; } else { if(isalpha(c)) { in_sentence = true; in_word = true; if(!iscapital(c)) errc++; } } } printf("%d",errc); }
void main(void){ char i,joker_runtime,j1,j2; *(char*)0x0328 = 0xfc; //block run/stop cputc(0x8); //block shift-cbm // *(char*)0xd020 = 0x03; // cgetc(); clrscr(); setgfx(0x0428); revers(1);textcolor(15);cputsxy(5,11,"[l]oad or [r]eset highscores?"); if (yesno()){ load_hs(); } else{ for(i=0;i<10;++i){ strcpy (highscore[i].name,"----------"); highscore[i].level = 0; highscore[i].score = 0; } } while (1){ ass_setup(); memmove((char*)0xe000,&bmp_data,LINES*320); memmove((char*)0xcc00,(char*)(&bmp_data + LINES*320),LINES*40); title_screen(); memset((char*)0xdbc0,15,40); level = score[0] = xpos1 = ypos1 = joker = time_out = no_more_moves_flag = 0; if (players){ xpos2 = 1; ypos2 = score[1] = 0; } time1 = 160; animals = 7; while (1){ if (time_out){ stop = 1; vic->spr_ena = 0; init_msx(4); if (joker==0){ check_moves(); if (pm_x1 == pm_x2){ clone(pm_y1+1,pm_x1,1); print3x3(EMPTY_SYMB,pm_x1,pm_y1+1); } else{ clone(pm_y1,pm_x1+1,1); print3x3(EMPTY_SYMB,pm_x1+1,pm_y1); } clone(pm_y1,pm_x1,0); print3x3(EMPTY_SYMB,pm_x1,pm_y1); vic->spr_ena = 3; while (*(char*)0xdc00 != 111){ vic->spr_ena ^= 3; delay(30); } } else{ while(*(char*)0xdc00 != 111); //kill_joker(); } broesel(); time_out_screen(); break; } //check for level up for (i=0;i<animals;++i){ if (hits[i]) break; } if (level == 0 || i == animals){ stop = 1; kill_joker(); init_msx(((level%2)>>1) + 3); if (++level != 1){ broesel(); } if (level == 5){ animals = 8; } if (level == 17){ all_done(); time_out_screen(); break; } xpos1 = 3; ypos1 = 3; vic->spr7_x = 39+3*24; vic->spr7_y = 50+3*24; if (players){ xpos2 = ypos2 = 4; vic->spr6_x = 39+4*24; vic->spr6_y = 50+4*24; } else{ vic->spr6_x = vic->spr6_y = 0; } memset(hits,(level+2),8); level_up_screen(); init_msx(~level%2); print_matrix(); timer_delay = level_time[level-1]; memset((char*)0xdbc0,0x0f,40); stop = no_more_moves_flag = key = 0; } if (no_more_moves_flag){ stop = 1; no_more_moves(); print_matrix(); stop = no_more_moves_flag = 0; } if (!isstop()){ stop = 1; //kill_joker(); memcpy(backup,matrix,64); broesel(); pause_screen(); memcpy(matrix,backup,64); print_matrix(); stop = 0; } if (key == CH_F8){ stop = 1; //kill_joker(); key = 0; broesel(); break; } // if a joker exists, check its runtime and destroy if needed if(joker == 1 && (clock() - jok1)/CLOCKS_PER_SEC >= joker_runtime){ kill_joker(); if (!check_moves()){ stop = 1; no_more_moves(); print_matrix(); stop = no_more_moves_flag = 0; } } // if no joker exists, create one on random number if (joker == 0 && random() == 0xea && random() >= 0xff){ joker = 1; random(); random(); joker_x = random() & 7; joker_y = random() & 7; matrix[joker_y][joker_x] = JOKER_SYMB; while ((joker_runtime = random() & 7) < 3); jok1 = clock(); } // joystick if (demo){ if (*(char*)0xdc00 == 111 || *(char*)0xdc01 == 239){ //kill_joker(); broesel(); break; } if (cue_max == 0){ if (pm_x1 > xpos1){ for (i=0;i<(pm_x1-xpos1);++i) put2cue(119); } else{ for (i=0;i<(xpos1-pm_x1);++i) put2cue(123); } if (pm_y1 > ypos1){ for (i=0;i<(pm_y1-ypos1);++i) put2cue(125); } else{ for(i=0;i<(ypos1-pm_y1);++i) put2cue(126); } } while (cue_max); delay(50); // s_temp = score[0]; swap (xpos1,ypos1,pm_x2-pm_x1,pm_y2-pm_y1); /* if (score[0] == s_temp){ vic->bordercolor++; while(1); } */ delay(50); continue; } if((j1 = *(char*)(0xdc00 + tt)&0x7f) != nothing){ pl = 0; if (j1 == fire_up){ if (ypos1) swap (xpos1,ypos1,0,-1); } if (j1 == fire_down){ if (ypos1 < 7) swap(xpos1,ypos1,0,1); } if (j1 == fire_left){ if (xpos1) swap (xpos1,ypos1,-1,0); } if (j1 == fire_right){ if (xpos1 < 7) swap (xpos1,ypos1,1,0); } if (j1 == 111){ if (matrix[ypos1][xpos1] == JOKER_SYMB){ joker_hit(pl); } } } if (players){ if((j2 = *(char*)0xdc01) != 255){ pl = 1; if (j2 == 238){ if (ypos2) swap (xpos2,ypos2,0,-1); } if (j2 == 237){ if (ypos2 < 7) swap(xpos2,ypos2,0,1); } if (j2 == 235){ if (xpos2) swap (xpos2,ypos2,-1,0); } if (j2 == 231){ if (xpos2 < 7) swap (xpos2,ypos2,1,0); } if (j2 == 239){ if (matrix[ypos2][xpos2] == JOKER_SYMB){ joker_hit(pl); } } } } } }
bool ispunct(char c) { return (!iscapital(c) && !issmall(c) && !isstop(c)); }
SUBSTMAP read_substmap(char* filename) { FILE *f; SUBSTMAP map=calloc(sizeof(char **),256); char *path, line[1024], *p, *q; char s[256]; char stopchar; int escaped, lineno=0, i; unsigned int uc; path=find_file(filename,add_exe_path(map_path)); if (!path) { free(map); return(NULL); } if (!map) { fprintf(stderr,"Insufficient memory\n"); exit(1); } f=fopen(path,"rb"); if (!f) { perror("catdoc"); return NULL; } if (input_buffer) setvbuf(f,input_buffer,_IOFBF,FILE_BUFFER); while (!feof(f)) { if (!fgets(line,1024,f)) continue; lineno++; /* parse line */ /* skip leading space */ for(p=line;*p && isspace(*p);p++); /* if #, it is comment */ if (!*p || #ifdef __MSDOS__ *p==0x1A || /* DOS have strange habit of using ^Z as eof */ #endif *p=='#') continue; /* read hexadecimal code */ uc = strtol(p,&p,16); if (!isspace(*p)|| uc<0 || uc>0xfffd) { fprintf(stderr,"Error parsing %s(%d)\n",path,lineno); continue; } /* skip space between code and sequence */ for(;*p && isspace(*p);p++); if (!p) continue; switch (*p) { case '\'': case '"': stopchar=*p; break; case '(': stopchar=')'; break; case '[': stopchar=']'; break; case '{': stopchar='}'; break; default: p--; stopchar='\n'; } p++; q=p; escaped=0; while (*q && (!isstop(*q,stopchar) || escaped)) { if (escaped) { escaped=0; } else { escaped= (*q=='\\'); } q++; } if (*q!=stopchar && !(isspace(*q) && stopchar=='\n')) { fprintf(stderr,"Error parsing %s(%d): unterminated sequence\n", path,lineno); continue; } /* HERE SHOULD BE BACKSLASH ESCAPE PROCESSING !!!*/ *q=0; for (q=s,i=0;*p && i<256;q++,i++) { if (*p!='\\') { *q=*p++; } else { switch (*(++p)) { case 'n': *q='\n'; break; case 'r': *q='\r'; break; case 't': *q='\t'; break; case 'b': *q='\b'; break; case '\"': *q='\"'; break; case '\'': *q='\''; break; case '0': *q=strtol(p,&p,8); p--; break; case '\\': default: *q=*p; } p++; } } *q=0; if (i>longest_sequence) longest_sequence=i; map_insert(map,uc,s); } fclose(f); free(path); return map; }