RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

全部问题

Martin Hope
IgrikXD
Asked: 2020-10-26 23:46:53 +0000 UTC

C++数组指针

  • 10

让我们有一个静态数组:

short tell[20];

在哪里:

  1. tell- 数组第一个元素的地址(2 字节块)。
  2. &tell- 整个数组的地址(40 字节块)。

并且有以下构造,指向一个包含 20 个 short 类型元素的数组:

short (*pas)[20] = &tell

pas 的结果数据类型是 type: short (*)[20]。实际上问题是如何创建这种类型的变量并使用 new 操作为其分配内存?

该示例取自以下书籍:Stephen Prata - The C++ Programming Language(第 6 版)。页 182.

c++
  • 2 个回答
  • 10 Views
Martin Hope
Bim Bam
Asked: 2020-10-25 00:35:31 +0000 UTC

可以用css制作这个动画吗?

  • 10

在此处输入图像描述

有没有可能用CSS制作这样的动画,把某个凸起变成凹陷?如果是,那么用什么?

html
  • 2 个回答
  • 10 Views
Martin Hope
Saint
Asked: 2020-10-03 15:47:40 +0000 UTC

WPF游戏,将WinForms代码移植到MVVM

  • 10

我想实现:按钮排列成正方形(作为二维 NxN 数组)。单击按钮时,将旋转一行和一列中的所有按钮。数字 N 是可定制的。一开始我什么都做MainWindow.xaml.cs,他们建议我正常做一切并使用它MVVM。代码MainWindow.xaml.cs:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private Button[,] CreateButtons(int quantity)
    {
        Form.Rows = quantity;
        Form.Columns = quantity;
        Button[,] buttons = new Button[quantity, quantity];
        for (int i = 0; i < quantity; i++)
        {
            for (int j = 0; j < quantity; j++)
            {
                buttons[i, j] = new Button();
                buttons[i, j].Width = 100;
                buttons[i, j].Height = 20;
                buttons[i, j].Margin = new Thickness(5,80,0,0);
                buttons[i, j].Click += new RoutedEventHandler(new_button_click);
            }
        }
        return buttons;
    }

    void new_button_click(object sender, RoutedEventArgs e)
    {
        Button btn = sender as Button;
        if (btn != null)
        {
            var rotateTransform = btn.RenderTransform as RotateTransform;
            var transform = new RotateTransform(90 + (rotateTransform == null ? 0 : rotateTransform.Angle));
            transform.CenterX = 50;
            transform.CenterY = 10;
            btn.RenderTransform = transform;
        }
    }

    private void AddToWrapPanel(int quantity, Button[,] buttons)
    {
        for (int i = 0; i < quantity; i++)
            for (int j = 0; j < quantity; j++)
            {
                Form.Children.Add(buttons[i, j]);
            }
    }

    private int GetQuantityButtons()
    {
        ComboBoxItem item = (ComboBoxItem)comboBox1.SelectedItem;
        int count = int.Parse((string)item.Content);
        return count;
    }

    private void СreateButton_Click(object sender, RoutedEventArgs e)
    {
        if (Form.Children.Count > 0)
            Form.Children.Clear();
        int count = GetQuantityButtons();
        Button[,] buttons = CreateButtons(count);
        AddToWrapPanel(count, buttons);
    }
}

现在我开始移动所有东西。

XAML:

<Window x:Class="Di.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:user="clr-namespace:Di"
    Title="Сейф" Height="715.6" Width="840" Left="250" Top="10" Background="Silver" ResizeMode="CanMinimize"
    TextOptions.TextFormattingMode="Display" Icon="Resources/Icon1.ico">
<Window.DataContext>
    <user:MainWindowModel />
</Window.DataContext>
<Grid>
    <ItemsControl Margin="0,30,0,0">
        <UniformGrid x:Name="Form"/>
        <WrapPanel Name="wrapPanel" Background="#FFF2F2F2" />
    </ItemsControl>
    <Button Content="Старт" Height="23" HorizontalAlignment="Left" Margin="457,12,0,0" Name="createButton" VerticalAlignment="Top" Width="75" Click="СreateButton_Click" Command="{Binding Seter}" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="368,12,0,0" Name="comboBox1" VerticalAlignment="Top" Width="74" SelectedIndex="0" RenderTransformOrigin="0.5,0.739">
        <ComboBoxItem Content="{Binding Three}" />
        <ComboBoxItem Content="{Binding Four}" />
        <ComboBoxItem Content="{Binding Five}" />
        <ComboBoxItem Content="{Binding Six}" />
    </ComboBox>
    <Label Content="{Binding Lvl}" HorizontalAlignment="Left" Margin="254,10,0,0" VerticalAlignment="Top"/>
</Grid>

代码VM:

public class MainWindowModel
{
    public int Three { get; set; }
    public int Four { get; set; }
    public int Five { get; set; }
    public int Six { get; set; }
    public string Lvl { get; set; }

    public MainWindowModel()
    {
        Three = 3;
        Four = 4;
        Five = 5;
        Six = 6;
        Lvl = "Сложность (3 - 6):";
    }

    private ICommand _seter;

    public ICommand Seter
    {
        get
        {
            return _seter ?? (_seter = new RelayCommand(() =>
              {
                  // действие при вызове команды
              }));
        }

    }

}

到目前为止,只有这样.. 请帮助我转移并完成我计划的时刻。例如:如何VM在服务按钮中创建一个属性RotationAngle?单击“创建”然后使用它们时如何生成一组按钮?如何访问UniformGrid行数和列数并将其与所选中int的关联combobox?

c#
  • 1 个回答
  • 10 Views
Martin Hope
XelaNimed
Asked: 2020-09-30 16:35:06 +0000 UTC

通过文本值从枚举中提取常量

  • 10

有以下方法,它enum通过其字符串表示形式返回一个命名常量,或者在失败时返回一个默认值:

static TEnum GetEnum<TEnum>(string key, TEnum defaultValue = default(TEnum), bool ignoreCase = true) 
where TEnum : struct, IConvertible {
    TEnum result;
    return Enum.TryParse<TEnum>(key, ignoreCase, out result) ? result : defaultValue;
}

问题:为什么下面的代码会为一个不存在的常量返回错误的结果?如何解决?

enum Nums { none = 0, one, two, three, four, five }

Nums res;

res = GetEnum<Nums>("one");
Console.WriteLine($"{res} : {res == Nums.one}");   // one : True
res = GetEnum<Nums>("six");
Console.WriteLine($"{res} : {res == Nums.none}");  // none : True
res = GetEnum<Nums>("123");
Console.WriteLine($"{res} : {res == Nums.none}");  // 123 : False ???

我假设这是由于 string 的数字解释而发生的123,但仍然不清楚为什么会发生这种情况以及如何解决它?

c#
  • 3 个回答
  • 10 Views
Martin Hope
Malov Vladimir
Asked: 2020-09-28 03:40:04 +0000 UTC

list::size() 函数的线性复杂度是多少?

  • 10

其实有两个问题。令我自己有些惊讶的是,我了解到获取列表中项目数的时间复杂度std::list::size()是线性的

C++98。复杂性:最高为线性。资源

目前尚不完全清楚是什么原因造成的。为什么每次都要数你的物品?

如果这在早期标准中是必要的,那么由于哪些妥协,才有可能在新标准中实现稳定性保证?

C++11。复杂性:常数。

c++
  • 1 个回答
  • 10 Views
上一页
下一页

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5