小编Mic*_*tta的帖子

开始和结束一段CSS代码

当我使用样式CSS时,如下所示:

#test p{/*css code here*/}
#test span{/*css code here*/}
#test p.one{/*css code here*/}
#test span.test{/*css code here*/}
Run Code Online (Sandbox Code Playgroud)

然后#test每次选择带有id的div 更容易,如下所示:

begin #test
p{/*css code here*/}
span{/*css code here*/}
p.one{/*css code here*/}
span.test{/*css code here*/}
end #test
Run Code Online (Sandbox Code Playgroud)

这是CSS样式的好习惯吗?如果是这样,我希望这将被添加到CSS的未来版本中.

css

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

在HTML5中,请解释'?'的含义 在声明中

在HTML5中,'?'的含义是什么?在这个声明中?'?'之后内容的含义是什么?

<script type='text/javascript'
        src='http://mobile.smashingmagazine.com/wp-includes/js/thickbox/thickbox.js?ver=3.1-20121105'>
</script>
Run Code Online (Sandbox Code Playgroud)

javascript hyperlink

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

如何在C++代码中避免这些类型的内存泄漏?

我的C++代码存在内存泄漏问题.我认为这是因为指针分配.例如,我有几行像这样:

**int **p= new int *[g+2];          
for(int k=0;k<=g+1;k++){
    p[k]=new int [n_k[k]+1];
    for(int l=0;l<=n_k[k];l++){
        p[k][l]=0;
    }
}
int **temp= new int *[g+2];     
for(int k=0;k<=g+1;k++){
    temp[k]=new int [n_k[k]+1];
    for(int l=0;l<=n_k[k];l++){
        temp[k][l]=p[k][l];
    }
}
  ...
  ...
 for(int r=0; r<=g+1;r++){
delete []temp[r];
  }
  delete []temp;
  for(int r=0; r<=g+1;r++){
delete []p[r];
  }
   delete []p;
Run Code Online (Sandbox Code Playgroud)

我怎样才能避免这些内存泄漏?我删除指针,但我认为内存泄漏是由于指针分配.我在代码中多次使用过这样的指针赋值.

c++ pointers memory-leaks

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

有没有办法在C#中使用字符串名称创建文本文件?

我不确定是否可能.我通常创建这样的txt文件:

FileStream fs = new FileStream("c:\\textFile.txt", FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
Run Code Online (Sandbox Code Playgroud)

但不是使用"c:\ textFile.txt"我想使用字符串名称创建一个文件.有办法吗?

c# string filestream streamwriter text-files

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

laravel 4 Route :: controller()方法返回NotFoundHttpException

我正在尝试使用app/routes.php中的以下内容路由到RESTful控制器:

Route::controller('register', 'RegisterController');

Route::get('/', 'HomeController@showWelcome');
Run Code Online (Sandbox Code Playgroud)

在我的app/controllers/RegisterController.php文件中,我添加了以下内容:

<?php

class RegisterController extends BaseController 
{
    public function getRegister()
    {
        return View::make('registration');
    }

    public function postRegister()
    {
    $data = Input::all();
    $rules = array(
        'first_name' => array('alpha', 'min:3'),
        'last_name' => array('alpha', 'min:3'),
        'company_name' => array('alpha_num'),
        'phone_number' => 'regex:[0-9()\-]'
    );  
    $validator = Validator::make($data, $rules);
    if ($validator->passes()) {
        return 'Data was saved.';
    }
    return Redirect::to('register')->withErrors($validator);
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException

当我在终端运行php artisan路线时,我得到:

+--------+--------------------------------------------------+------+----------------------------+----------------+---------------+
| Domain | URI                                              | Name | Action                     | Before Filters | After Filters | …
Run Code Online (Sandbox Code Playgroud)

php controller laravel laravel-4

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

card.io将无法在64位iPhone 5s armv7s上编译

我在64位模式(armv7s)的iPhone 5s上编译card.io时遇到了麻烦.它将在模拟器上进行编译.我正在使用Xcode 5.

这是我的错误消息:

Undefined symbols for architecture armv7s:
  "_CMSampleBufferGetImageBuffer", referenced from:
      -[CardIOVideoFrame process] in libCardIO.a(CardIOVideoFrame.o)
  "_CMGetAttachment", referenced from:
      -[CardIOVideoStream captureOutput:didOutputSampleBuffer:fromConnection:] in libCardIO.a(CardIOVideoStream.o)
ld: symbol(s) not found for architecture armv7s
Run Code Online (Sandbox Code Playgroud)

armv7 card.io ios7

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

为什么我的Python代码,了解"if"语句,无法工作?

我正在努力学习有关if陈述的更多信息.我试图创建一个程序,要求用户输入啤酒量,并在金额增加时输出不同的答案.我无法弄清楚我做错了什么.

我期望发生的是当我输入数字时,例如.5结果应该是"啤酒很棒".因为它低于50.如果我输入60,它应输出"那是很多啤酒." 因为它高于50且低于100.

我已经阅读了Python文档,但仍然没有弄明白.这是我的代码:

print "How many cans of beer do you want?"

beer = raw_input("Enter your amount: ")

if beer >= 1:
    print "Beer is awesome."
elif beer >= 50:
    print "That's a lot of beer."
elif beer >= 100:
    print "You're drinking way too much beer, man."
else:
    "Did you make a choice larger than 100? If yes, then you're crazy!"
Run Code Online (Sandbox Code Playgroud)

python if-statement

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

为什么我的BMI平均代码无法正常工作?

我试图计算一些人的平均BMI.当我运行此代码时,每次单击计算按钮时平均BMI都会下降.为什么?

float feet;
float inches;
float height;
float weight;
float bmi;
float averagebmi;

try
{
    //Get user input.
    feet = float.Parse(txtFeet.Text);
    inches = float.Parse(txtInches.Text);
    weight = float.Parse(txtWeight.Text);

    //Calculations.
    inches += feet * 12;
    height = inches * (float)0.0254;
    weight = weight * (float)0.453592;
    bmi = weight / (height * height);

    //Manager Calculations.
    totalPeople += 1;
    bmi += 1;
    averagebmi = bmi / totalPeople;
Run Code Online (Sandbox Code Playgroud)

c#

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

如何检查字符串数组中的元素是否为空?

如何检查字符串数组中的元素是否为空?这是我的示例数组:

private static String correct[] = new String[5];
    static {
        correct[1] = "some texT";
        correct[2] = "some texT3";
        correct[4] = "some texT2";
}
Run Code Online (Sandbox Code Playgroud)

我可以分配null其余的元素,但我想找到另一个更好的方法来做到这一点.我找到了isEmpty,但它仅适用于API 9及更高版本.

if(correct[0].length() > 0) 给我一个NPE. if(correct[0] != null也.

java

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

为什么我的骰子抛出程序会卡住?

我的程序应该在一个数组中滚动一对骰子1000次,然后在最后吐出每个数字的频率.我以为我做得对,但它在运行时一直卡在++上.怎么了,怎么解决呢?

import java.util.Random;
public class dice {
    public static void main (String[] args)
    {
        Random rand = new Random();
        int[] counter = new int[12];
        for (int i = 0 ; i<1000; i++)
        {
            int roll1 = rand.nextInt(6) + 1;
            int roll2 = rand.nextInt(6) + 1;
            int sum = roll1 + roll2; 
            counter[sum]++;
        }
        System.out.println("***********Results************");
        for (int j=0; j<13; j++)
        {
            System.out.println(j+"  occured  "+counter[j]+" times");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java arrays random

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