小编Jor*_*leo的帖子

尝试通过递归更优雅地解决电话词

我已经查看了Stack Overflow,但却无法获得任何工作.如果我错过了一个明显明显的帖子,我道歉.

我有一个学校问题,包括取一个电话号码,获得所有可能的单词组合,然后将其写入文本文件.我做到了这一点,并完全归功于我的任务.我能够用七个嵌套循环做到这一点,但这不是很优雅,而且非常严格.我被吹走了,完全失望地发现教科书解决方案是七个嵌套循环.我的导师也没有任何答案.

我尝试了很多不同的方法,但是我无法将其拨入.我确定了一个递归和杀点,但从来没有能够让它工作.我可以制作字母序列,但不知道应该有多少.我评论了我的尝试,所以你可以看到我失败的思考过程:)请看看,如果你有任何想法,请告诉我.

public partial class TelephoneWorderizer : Form
{
    protected Dictionary<int, IEnumerable<string>> KeyMappings = new Dictionary<int, IEnumerable<string>>();
    protected string[][] ActiveLettersGroups = null;
    protected List<string> Words = new List<string>();
    protected List<string> RecursiveWords = new List<string>();
    protected int Iteration = 0;

    public TelephoneWorderizer()
    {
        InitializeComponent();

        this.KeyMappings = this.GetKeyMappings();
    }

    private void btnGetWords_Click(object sender, EventArgs e)
    {
        string textBoxContent = textBoxNumber.Text;

        int[] digits = this.GetPhoneNumbers(textBoxContent);

        List<string> words = this.GetWords(digits);

        using (StreamWriter writer = new StreamWriter(@"E:\words.txt"))
        {
            foreach (var word in words) …
Run Code Online (Sandbox Code Playgroud)

c# linq recursion loops

12
推荐指数
1
解决办法
2148
查看次数

Aframe 注销组件

我正在学习如何使用 React 和 Redux 构建框架。我正在创建自定义组件并将它们注册到我的reactjs componentWillMount 生命周期事件中。例如:我将光线投射的结果发送到父级 React 组件,以保存用于其他目的。这很好用。

import React, {Component, PropTypes} from 'react'

export default class AframeComponent extends Component {
  static propTypes = {
    cb: PropTypes.func.isRequired
  }

  componentWillMount () {
    const {AFRAME} = window
    const aframeComponent = this

    if (!AFRAME) return

    if (!AFRAME.components['sphere-listener']) {
      AFRAME.registerComponent('sphere-listener', {
        init () {
          const {el} = this
          el.addEventListener('mouseup', (evt) => {
            const camera = document.querySelector('#camera')
            aframeComponent.handleRaycast(evt.detail.intersection.point, camera.components.rotation)
          })
        }
      })
    }
  }

  handleRaycast (position, rotation) {
    const {cb} = this.props

    /* do …
Run Code Online (Sandbox Code Playgroud)

reactjs aframe

6
推荐指数
1
解决办法
1809
查看次数

标签 统计

aframe ×1

c# ×1

linq ×1

loops ×1

reactjs ×1

recursion ×1