小编use*_*830的帖子

c中改进的qsort()函数

假设我们正在使用qsort()对一维数组进行排序,是否有一种简单的方法可以从排序数组的元素中检索索引,这是元素在排序之前在数组中编入索引时所具有的.假设c [N]变为d [N],如何从整数i,j中找到c [j] = d [i]?当我的意思是一种简单的方法时,qsort(带有一些额外的参数)是否存储了这种信息(在排序之前的索引之间进行双射)或者它是否存在可以轻松排序和检索此类信息的qsort改进函数?

c sorting

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

如何hexdump大文件

我想输出8go文件的hexdump结果.是否有可能一件一件地做?如何指定有限数量的行(我已阅读手册页,它似乎对应于-n长度,但它不起作用)

hexdump

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

Jquery inArray()方法在Jquery对象中查找一个类

假设我有一个Jquery对象$('.class0 .class1 .class2...').我想检查一个类.classX是否在这个对象中.我怎样才能做到这一点?我认为inArray()不适应

同时,为了让事情更清楚,如果我有一个Jquery对象,$('.class0, .class1, .class2, ...')如果我想检查一个类.classX是否在这个对象中,我应该使用inArray()方法,对吧?

javascript arrays jquery

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

execption notifier gem问题

exception_notifier在这之后安装了gem http://railscasts.com/episodes/104-exception-notifications-revised.但是在跑步的时候rails s,我得到了这个

/home/ruby-2.0.0-p195/gems/actionpack-3.2.13/lib/action_dispatch/middleware/stack.rb:43:in `build': undefined method `new' for ExceptionNotifier:Module (NoMethodError) 
Run Code Online (Sandbox Code Playgroud)

所以我试图谷歌这个问题,我发现我可以在我的production.rb文件中使用config.middleware.use ExceptionNotifier::Rack...这个问题config.middleware.use ExceptionNotifier...

但后来我收到了这条消息:

uninitialized constant ExceptionNotifier::Rack (NameError)
Run Code Online (Sandbox Code Playgroud)

我该如何处理这个gem安装?

ruby ruby-on-rails exception exception-notifier

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

C中的二进制分解

我正在编写一些东西来分解训练网站上的二进制数字.我在我的本地编译器上测试了一百次,它运行得很好,但是训练网站告诉我有错误.

(我的代码既不优雅也不高效,尤其是循环,但我分解了代码以了解错误的位置).有人能告诉我是否有错误吗?

#include <stdio.h>
#include <stdlib.h>


//function that displays the greatest power of 2 less than a fixed number N
int residu(int N)

{
    int i;
    int M=2;
    for(i=0;i<N;i++){
        if(M>N){break;}else{M=2*M;i++;}
    }
    return M/2;
}


int main()
{
    int i;

    //N is the input to decompose
    int N;
    scanf("%d",&N);
    //We will search for the greatest power of 2 less than a fixed number N, 
    //than repeating the some process with the residue of N with the greatest power of 2        //less …
Run Code Online (Sandbox Code Playgroud)

c binary

0
推荐指数
1
解决办法
1472
查看次数

缩进问题python

我是python的新手,当我评论('#')以下代码的最后两行时,我有一个缩进错误消息:

    try:
        return get_callable(callback), {}
#   except (ImportError, AttributeError), e:
#       raise ViewDoesNotExist("Tried %s. Error was: %s" % (callback, st    r(e)))
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

python comments indentation

0
推荐指数
1
解决办法
77
查看次数

who belongs_to who - 嵌套模型 - rails

假设我有一个用户表和一个活动表(带有user_id列),并且每个活动都有一个创建者(谁是用户),以及一个成员列表,他们也是(用户).所以我有

class UsersController < ApplicationController
  has_many :campaigns
Run Code Online (Sandbox Code Playgroud)

class CampaignsController < ApplicationController

  belongs_to :user 
  has_many :users 
  accept_nested_attributes_for :users
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:ActionController::RoutingError (undefined methodbelongs_to'for CampaignsController:Class)`

database controller model ruby-on-rails

0
推荐指数
1
解决办法
67
查看次数

在c中反转一个单词

这肯定很简单,但我是C的新手,我不明白为什么下面的代码是错误的.代码是字符串的简单恢复字符位置:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{   int i,length;
    char *word;
    scanf("%s",word);
    length = strlen(word);
    char res[length];

    for(i=0;i<length;i++){
        res[i]=word[length-1-i];
        printf("%d",res[i]);}
}
Run Code Online (Sandbox Code Playgroud)

当我输入一个字符串时,我在控制台和调试器中收到一条消息:(lldb):movb%al,(%rcx),EXC_BAD_ACCESS(code = 1,address = 0x0)

c string

-3
推荐指数
1
解决办法
173
查看次数

从数组中移位和提取 - php

可能重复:
来自大数组的子数组

假设我有一个包含N个条目的数组.给定两个整数n和m我对从行n到行m的条目感兴趣.假设该值只能取两个值val0和val1

n => [val0]
n+1=> [val0]
n+2 => [val1]
...
m=> [val0]
Run Code Online (Sandbox Code Playgroud)

然后我想提取一个返回的子数组(像移位运算符一样):

0 => [val0]
1 => [val0]
2 => [val1]
...
m-n => [val0]
Run Code Online (Sandbox Code Playgroud)

php arrays

-3
推荐指数
1
解决办法
71
查看次数