12
#include<stdio.h> #include<malloc.h> #define SIZE 4 #define TRUE 1 #define FALSE 0 int getConsecutive_Number(char *phone_number,char number){ int temp1=number; int temp=FALSE; int i; for(i=0;i<SIZE;i++){ if(number++==phone_number[i]) temp=TRUE; else{ temp=FALSE; break; } } if(temp) return 5; else{ temp=FALSE; number=temp1; } for(i=0;i<SIZE;i++){ if(number--==phone_number[i]) temp=TRUE; else{ temp=FALSE; break; } } if(temp) return 5; else return 0; } int getPrefix_or_Suffix_number(char *phone_number,char number){ int i,score=0; int temp=FALSE; for(i=0;i<SIZE-1;i++){ if(number==phone_number[i]) temp=TRUE; else{ temp=FALSE; break; } } if(temp) score+=3; number=phone_number[1]; for(i=1;i<SIZE;i++){ if(number==phone_number[i]) temp=TRUE; else{ temp=FALSE; break; } } if(temp) score+=3; return score; } int getAABB_or_ABAB(char *phone_number){ int score=0; int i; if((phone_number[0]==phone_number[1]) && (phone_number[2]==phone_number[3])) score++; if((phone_number[0]==phone_number[2]) && (phone_number[1]==phone_number[3])) score++; return score; } int getSix_Eight_Nine(char *phone_number){ int i,score=0; for(i=0;i<SIZE;i++){ if(phone_number[i]=='6' || phone_number[i]=='8' || phone_number[i]=='9'){ score++; } } return score; } int main(void){ char phone_number[SIZE]; int i=0; int total_grade=0; gets(phone_number); total_grade+=getConsecutive_Number(&phone_number[0],phone_number[0]); total_grade+=getPrefix_or_Suffix_number(&phone_number[0],phone_number[0]); total_grade+=getAABB_or_ABAB(&phone_number[0]); total_grade+=getSix_Eight_Nine(&phone_number[0]); printf("%d",total_grade); return 0; }