小编Nov*_*vak的帖子

时间跨度由一个数字划分

我有一个生成时间跨度的代码来计算某个动作的持续时间.我想要做的是取结果(持续时间)并除以一个数字,任何数字.

我怎样才能做到这一点?

c# timespan

22
推荐指数
4
解决办法
1万
查看次数

将子项附加到网格,设置它的行和列

如何将Image对象附加到a Grid并设置它的

网格是3x3.

主文件:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="440" Width="400" ResizeMode="NoResize">
    <Window.Background>
        <ImageBrush ImageSource="C:\Users\GuyD\AppData\Local\Temporary Projects\WpfApplication1\AppResources\Background.png"></ImageBrush>
    </Window.Background>
    <Grid ShowGridLines="True" x:Name="myGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="42" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="32*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="31*" />
            <ColumnDefinition Width="26*" />
            <ColumnDefinition Width="32*" />
        </Grid.ColumnDefinitions>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

代码隐藏文件:

public MainWindow()
{
     InitializeComponent();
     for (int i = 0; i < 3; i++)
     {
          for (int j = 0; j < 3; j++)
          {
               Image …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml gridview

22
推荐指数
2
解决办法
5万
查看次数

调整大小后获取实际图像大小

我有一个填充缩略图的页面,用css调整大小150x150,当我点击缩略图时,页面变暗,并且图像显示为真实尺寸.

目前,我必须手动创建一个包含所有图像的实际高度的数组.为了解决设计问题+减少我的图库的手动操作,我需要在调整大小(CSS)后获得图像的实际高度.

我试过了:

var imageheight = document.getElementById(imageid).height;
Run Code Online (Sandbox Code Playgroud)

和:

var imageheight = $('#' + imageid).height();
Run Code Online (Sandbox Code Playgroud)

但两者都返回150pxCSS分配的属性.我怎么解决这个问题?谢谢

javascript css jquery

14
推荐指数
2
解决办法
9989
查看次数

使用PHPExcel添加新行?

如何使用PHPExcel向现有的.xls文件添加新行?

我是否必须计算已存在的行数?

如果是这样,我如何为excel文件执行此操作?

php phpexcel

12
推荐指数
2
解决办法
3万
查看次数

Javascript将事件附加到类名

如果我有10个项目,使用班级名称keyword:

<div class="keyword"></div>
Run Code Online (Sandbox Code Playgroud)

如何click在此元素上附加事件.

我试过以下,但没有运气:(没有警报出现)

document.getElementsByClassName('.keyword').onclick = function()
{
    alert(true);
    Search.addKey(this.getElementsByClassName('name')[0].innerHTML);
}
Run Code Online (Sandbox Code Playgroud)

要求:

  • 没有onclick属性
  • 没有jQuery或任何其他库

注意:页面加载时不会生成元素.它们的数量可以不同,每次单击按钮例如.

我需要一种方法来附加所有标签,并在'future'中使用'keyword'类.

javascript

10
推荐指数
1
解决办法
1万
查看次数

C#isPowerOf函数

我有下一个功能:

static bool isPowerOf(int num, int power)
{
        double b = 1.0 / power;
        double a = Math.Pow(num, b);
        Console.WriteLine(a);
        return a == (int)a;
}
Run Code Online (Sandbox Code Playgroud)

我插入了打印功能进行分析.

如果我调用该函数:

isPowerOf(25, 2)
Run Code Online (Sandbox Code Playgroud)

5^2等于25后返回true.但是,如果我调用16807,那就是7^5下一个方法:

isPowerOf(16807, 5)
Run Code Online (Sandbox Code Playgroud)

在这种情况下,它打印'7'但a == (int)a返回false.

你能帮我吗?谢谢!

c# math exponentiation

7
推荐指数
2
解决办法
375
查看次数

修剪时realloc会失败(返回NULL)吗?

如果做下一个:

int* array = malloc(10 * sizeof(int));
Run Code Online (Sandbox Code Playgroud)

他们使用realloc:

array = realloc(array, 5 * sizeof(int));
Run Code Online (Sandbox Code Playgroud)

在第二行(并且只有它),它可以返回NULL吗?

c memory-management realloc

7
推荐指数
2
解决办法
1359
查看次数

计算已排序数组中数字的出现次数

我的老师给了我下一个任务:

On a sorted array, find the number of occurrences of a number.
The complexity of the algorithm must be as small as possible.
Run Code Online (Sandbox Code Playgroud)

这就是我的想法:

public static int count(int[] a, int x)
{
    int low = 0, high = a.length - 1;

    while( low <= high )
    {
        int middle = low + (high - low) / 2;

        if( a[middle] > x ) {
            // Continue searching the lower part of the array
            high = middle - 1;
        } else …
Run Code Online (Sandbox Code Playgroud)

java

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

项目欧拉解决方案#14

我有以下问题(来自ProjectEuler.net - 问题14)

为正整数集定义以下迭代序列:

n -> n/2 (n is even)
n -> 3n + 1 (n is odd)
Run Code Online (Sandbox Code Playgroud)

使用上面的规则并从13开始,我们生成以下序列:

13 ? 40 ? 20 ? 10 ? 5 ? 16 ? 8 ? 4 ? 2 ? 1
Run Code Online (Sandbox Code Playgroud)

可以看出,该序列(从开始13和结束1)包含10个术语.虽然尚未证实(Collat​​z问题),但据认为所有起始数字都已完成1.

哪个起始编号低于一百万,产生最长的链?

注意:链条启动后,条款允许超过一百万.

我用了:

   static int road (int n)
   {
       int road = 0;
       while (n != 1)
       {
           if (n % 2 == 0)
               n = n / 2;
           else
               n = 3 * …
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
1
解决办法
875
查看次数

C编程语言书的例子:可能已经过时了?

我开始学习C和我的一个朋友(比我大),The C Programming LanguageBrian KernighanDennis Ritchie建议.

然而,在尝试一些例子时,他们的行为与预期不同,而不是书中所写.

例如,这个,似乎不起作用(什么都不打印):

#include <stdio.h>

#define IN 1
#define OUT 0

/* count lines, words, and characters in input */

int main()
{
   int c, nl, nw, nc, state;
   state = OUT;
   nl = nw = nc = 0;

   while ((c = getchar()) != EOF) {
      ++nc;
      if (c == '\n')
         ++nl;
      if (c == ' ' || c == '\n' || c == '\t')
         state = OUT;
      else …
Run Code Online (Sandbox Code Playgroud)

c

4
推荐指数
1
解决办法
3341
查看次数

标签 统计

c# ×4

c ×2

javascript ×2

css ×1

exponentiation ×1

gridview ×1

java ×1

jquery ×1

math ×1

memory-management ×1

php ×1

phpexcel ×1

realloc ×1

timespan ×1

wpf ×1

xaml ×1