1 条题解

  • 0
    @ 2021-6-15 12:57:58

    C :

    #include<stdio.h>
    #include<string.h>
    int main()
    {int i,n;
     char k[3000];
     static char a[4]="one",b[4]="two",c[6]="three",d[5]="four",e[5]="five",f[4]="six",g[6]="seven"; 
     scanf("%d",&n);
     for(i=0;i<n;i++)
     { scanf("%s",k);
       if(strstr(k,a)!=0&&strstr(k,b)!=0&&strstr(k,c)!=0&&strstr(k,d)!=0&&strstr(k,e)!=0&&strstr(k,f)!=0&&strstr(k,g)!=0)
    	   printf("Yes\n");
       else
    	   printf("No\n");
     }
     return 0;
    }
    

    C++ :

    #include <stdio.h>
    #include <string.h>
    #include <fstream>
    #include <iostream>
    using namespace std;
    
    int main(void)
    {
        int n;
        /*ifstream cin;
        ofstream cout;
        cin.open("b.in");
        cout.open("b.out");*/
        cin>>n;
        while(n--)
        {
            string s;
            int x1=0,x2=0,x3=0,x4=0,x5=0,x6=0,x7=0,sum=0,i;
            cin>>s;
            for(i=0;i<s.length();i++)
            if(i+2<s.length()&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'&&x1==0) {x1=1;sum++;}
            else if(i+2<s.length()&&s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o'&&x2==0) {x2=1;sum++;}
            else if(i+4<s.length()&&s[i]=='t'&&s[i+1]=='h'&&s[i+2]=='r'&&s[i+3]=='e'&&s[i+4]=='e'&&x3==0) {x3=1;sum++;}
            else if(i+3<s.length()&&s[i]=='f'&&s[i+1]=='o'&&s[i+2]=='u'&&s[i+3]=='r'&&x4==0) {x4=1;sum++;}
            else if(i+3<s.length()&&s[i]=='f'&&s[i+1]=='i'&&s[i+2]=='v'&&s[i+3]=='e'&&x5==0) {x5=1;sum++;}
            else if(i+2<s.length()&&s[i]=='s'&&s[i+1]=='i'&&s[i+2]=='x'&&x6==0) {x6=1;sum++;}
            else if(i+4<s.length()&&s[i]=='s'&&s[i+1]=='e'&&s[i+2]=='v'&&s[i+3]=='e'&&s[i+4]=='n'&&x7==0) {x7=1;sum++;}
            if(sum==7)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        return 0;
    }
    
    

    Java :

    import java.util.Scanner;
    public class Main {
    	public static void main(String[] args) {
    		Scanner reader=new Scanner(System.in);
    		int T=reader.nextInt();
    		Main t=new Main();
    		for(int i=0;i<T;i++){
    			String s=reader.next();
    			if(t.se(s)) System.out.println("Yes");
    			else System.out.println("No");
    		}
    	}
    	public boolean se(String s){
    		int i1=s.indexOf("one");
    		int i2=s.indexOf("two");
    		int i3=s.indexOf("three");
    		int i4=s.indexOf("four");
    		int i5=s.indexOf("five");
    		int i6=s.indexOf("six");
    		int i7=s.indexOf("seven");
    		if(i1>=0&&i2>=0&&i3>=0&i4>=0&&i5>=0&i6>=0&i7>=0)
    		return true;
    		else return false;
    	}
    }
    
    
    • 1

    信息

    ID
    809
    时间
    5000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者