Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX_LEN 8
- main(){
- char numeri[10][MAX_LEN]={"zero", "uno", "due", "tre", "quattro", "cinque", "sei", "sette", "otto", "nove"}, temp[MAX_LEN];
- FILE * fp;
- int i, n=0, m=0;
- ((fp=fopen("numeri.txt", "r"))!=NULL)?:(exit(0));
- while(feof(fp)==0){
- fscanf(fp, "%s", temp);
- for(i=0;i<10;i++)
- if((strcmp(numeri[i], temp))==0){
- m*=10;
- m+=i;
- }
- else if((strcmp("stop", temp))==0){
- n+=m;
- m=0;
- }
- }
- printf("%d\n", n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment