zoukankan      html  css  js  c++  java
  • 有序选择L长度排列

    http://acm.pku.edu.cn/JudgeOnline/problem?id=3049

    参考别人代码写的:

     

    #include<stdio.h>
    
    int  L, C;
    char list[27], set[27];
    
    void find(int i, int vovel, int ith)
    {
    	if(ith == L)
    	{
    		if(vovel)	printf("%s\n", set);
    		return ;
    	}
    	for(; i<=C-L+ith; i++)
    	{
    		set[ith] = list[i];
    		find(i+1, vovel+(set[ith] == 'a' || set[ith] == 'e' || set[ith] == 'i' || set[ith] == 'o' || set[ith] == 'u'), ith+1);
    	}
    }
    
    int main()
    {
    	int i, k, arr[123];
    	char temp[2];
    	while(scanf("%d%d", &L, &C) != EOF)
    	{
    		for(i='a'; i<='z'; i++)
    			arr[i] = 0;
    		for(i=0; i<C; i++)
    		{
    			scanf("%s", temp);
    			arr[temp[0]] = 1;
    		}
    		for(i='a', k=0; i<='z'; i++)
    			if(arr[i])
    				list[k++] = i;
    		set[L] = 0;
    		find(0, 0, 0);
    	}
    	return 0;
    }
    

  • 相关阅读:
    随笔
    我的舅舅
    代码规范
    SpringMVC_乱码问题
    SpringMVC_接受请求及数据回显
    Restful风格
    第六周总结
    SpringMVC_控制器
    SpringMVC_初次使用
    SpringMVC_简介
  • 原文地址:https://www.cnblogs.com/submarinex/p/1941247.html
Copyright © 2011-2022 走看看