Poj 3602 typographical ligatures

Source: Internet
Author: User

[Description]: the meaning of the question is to enter a string and ask how many different types of characters we have. That is to say, once a character appears, it will not be counted in the next time, especially ff, fi, FL, FFI, FFL.

[Analysis]: After briefly explaining the meaning of the question, we can solve the problem.

Code:

// 196K 0Ms#include<cstdio>#include<cstring>#include<iostream>using namespace std;char s[1000];int count1[1000];int ff[7];int len;void solve(){int ans = 0;memset(count1,0,sizeof(count1));memset(ff,0,sizeof(ff));for(int i = 0;i<len;i++){if(s[i] == 'f'){if(s[i+1] == 'f' && (s[i+2] == 'i' || s[i+2]=='l')){if(s[i+2] == 'i')ff[0]=1;if(s[i+2] == 'l')ff[1]=1;i+=2;}else if(s[i+1]=='f'||s[i+1]=='i'||s[i+1]=='l'){if(s[i+1]=='f')ff[2]=1;if(s[i+1]=='i')ff[3]=1;if(s[i+1]=='l')ff[4]=1;i++;}elsecount1[s[i]]=1;}else if(s[i]=='`'&&s[i+1]=='`'){ff[5]=1;i++;}else if(s[i]=='\''&&s[i+1]=='\''){ff[6]=1;i++;}elsecount1[s[i]]=1;}for(int i = 0;i<=256;i++)if(count1[i]) ans++;for(int i = 0;i<7;i++)if(ff[i]) ans++;cout<<ans<<endl;}int main(){char c;len = 0;while(cin>>c){if(c == EOF) break;if(c == ' '||c == '\n') continue;s[len++] = c;}solve();return 0;}


Poj 3602 typographical ligatures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.