GVKun编程网logo

recursion安全设置(security option安全设置选项可设置为)

4

如果您对recursion安全设置感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于recursion安全设置的详细内容,我们还将为您解答securityoption安全设置选

如果您对recursion安全设置感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于recursion安全设置的详细内容,我们还将为您解答security option安全设置选项可设置为的相关问题,并且为您提供关于4 Ways to Check the Current PowerShell Version on Your PC、6.递归(Recursion)、com.vmware.vim25.EventFilterSpecRecursionOption的实例源码、C语言 function recursion函数递归详解的有价值信息。

本文目录一览:

recursion安全设置(security option安全设置选项可设置为)

recursion安全设置(security option安全设置选项可设置为)

我想将文件夹的安全设置应用于C#中的所有后代。 从本质上讲,我想做''在[文件夹]的高级安全设置“中的''replace所有具有这个对象的可inheritance权限的后代的所有现有inheritance权限''。

有没有什么优雅的方法来处理这个问题?

Debian / Linux组权限不能正常工作

使用PHP复制Windows服务器上的文件

使用PHP在Windows中设置文件权限

PHP mkdir或chmod 0777不起作用

什么是正确的Windows文件夹在本地用户之间交换数据?

经过一段时间的谷歌和MSDN我想出了以下代码。 似乎工作得很好。

static void Main(string[] args) { DirectoryInfo dInfo = new DirectoryInfo(@"C:TestFolder"); DirectorySecurity dSecurity = dInfo.GetAccessControl(); ReplaceAllDescendantPermissionsFromObject(dInfo,dSecurity); } static void ReplaceAllDescendantPermissionsFromObject( DirectoryInfo dInfo,DirectorySecurity dSecurity) { // copy the DirectorySecurity to the current directory dInfo.SetAccessControl(dSecurity); foreach (FileInfo fi in dInfo.GetFiles()) { // Get the file''s FileSecurity var ac = fi.GetAccessControl(); // inherit from the directory ac.SetAccessRuleProtection(false,false); // apply change fi.SetAccessControl(ac); } // Recurse into Directories dInfo.GetDirectories().ToList() .ForEach(d => ReplaceAllDescendantPermissionsFromObject(d,dSecurity)); }

您可能会发现DirectorySecurity类对此很有用。

http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.directorysecurity.aspx

在System.Security.AccessControl命名空间中可能还有一些其他有价值的工具

总结

以上是小编为你收集整理的recursion安全设置全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

4 Ways to Check the Current PowerShell Version on Your PC

4 Ways to Check the Current PowerShell Version on Your PC

Introduction

If you are reading this guide because you want to learn how to find the PowerShell version on your computer,you are in the right place!

This guide details 4 ways you can check the version of PowerSell on your computer.

4 Ways to Get the PowerShell Version on your PC

If you want to determine the version of PowerShell on your computer,use one of the methods/commands discussed below:

Method 1: Get PowerShell Version with $PsversionTable Automatic Variable

copy and paste the command below into a PowerShell console and press Enter

$PsversionTable

Here is the result

 

My current PS version is 5.1.17134.858 but the result contains other information which you may not need.

To display just the version number,use the command below

$PsversionTable.Psversion

Here is the result

 

The last command provides a bit more information. We Now kNow that 5,1,17134,858 represents Major,Minor,Build and Revision numbers.

To display just the Major number,use this command:

$PsversionTable.Psversion.Major

Method 2: Get PS Version with Get-Variable PsversionTable Command

You can also get your PS version using the command below:

powershell -command "(Get-Variable PsversionTable -ValueOnly).Psversion"

The result is the same as the last command

 

Method 3: Get PowerShell Version with Get-Host Command

Here is another command that will give your PS version

Get-Host

The command returned a result with the full version details

 

If you want just the version number,you can use any of the 3 commands below:

Get-Host | Select-Object Version

This command will expand the version numbers

Get-Host | Select-Object -ExpandProperty Version

(Get-Host).Version

The last two commands product the same result. Here are the results of the 3 commands

 

If you want to display just the Major PowerShell version,use this command:

(Get-Host).Version.Major

Method 4: Get Powershell Version with $Host Automatic Variable

To use this method type the following command into a PowerShell prompt. Then press Enter.

$Host

Below is the result of the command in PowerShell

 

As you can see,the result is the same as using the Get-Host Command

Here is an example:

 

Conclusion

There are so many reasons you may want to determine the PowerShell version. It may be that you wrote a script that requires a minimum version to run successfully. No matter your reason,I hope it met your need!

If you have any question or want to leave a comment,use the “Leave a Reply” form at the end of this script. Alternatively,you Could share your experience working with PowerShell versions.

 

6.递归(Recursion)

6.递归(Recursion)

递归:

        自己调用自己的方法。分为两个阶段,一个是递:调用的过程。
                                                                 一个是归:结果返回的过程。

示例:

        一:三角数的求法(1,3,6,10,15..........)

        二:fibonacci数列的求法(第n项等于第n-1项与第n-2项的和)

public class Recursion {
    //三角数
    public int triangle(int i){
        if (i == 1){
            return 1;
        }
        return i+triangle(i-1);
    }
    //fibonacci数列
    public int fibonacci(int i){
        if (i==1){
            return 0;
        }
        if (i==2){
            return 1;
        }
        return fibonacci(i-1)+fibonacci(i-2);
    }
    public static void main(String[] args) {
        Recursion recursion = new Recursion();
        System.out.println(recursion.triangle(5));
        System.out.println(recursion.fibonacci(7));
    }
}

 

com.vmware.vim25.EventFilterSpecRecursionOption的实例源码

com.vmware.vim25.EventFilterSpecRecursionOption的实例源码

项目:vijava    文件:VMEventsMonitor.java   
private void createEventHistoryCollector() throws Exception
{
    // Create an Entity Event Filter Spec to
    // specify the MoRef of the VM to be get events filtered for
    EventFilterSpecByEntity entitySpec = new EventFilterSpecByEntity();
    entitySpec.setEntity(_rootFolder.getMOR());
    entitySpec.setRecursion(EventFilterSpecRecursionoption.children);

    // set the entity spec in the EventFilter
    EventFilterSpec eventFilter = new EventFilterSpec();
    eventFilter.setEntity(entitySpec);

    // we are only interested in getting events for the VM.
    // Add as many events you want to track relating to vm.
    // Refer to API Data Object vmEvent and see the extends class list for
    // elaborate list of vmEvents
    eventFilter.setType(new String[] { "VmPoweredOffEvent","VmPoweredOnEvent","VmSuspendedEvent","VmRenamedEvent" });

    // create the EventHistoryCollector to monitor events for a VM
    // and get the ManagedobjectReference of the EventHistoryCollector
    // returned
    _eventHistoryCollector = _eventManager
            .createCollectorForEvents(eventFilter);
}
项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
private EventHistoryCollector createEventHistoryCollector(Managedobject mo,String[] events) throws InvalidState,RuntimeFault,remoteexception
{
    if (eventManager == null) {
        s_logger.error("Cannot create EventHistoryCollector,eventManager is null");
        return null;
    }
    EventFilterSpec eventFilterSpec = new EventFilterSpec();
    eventFilterSpec.setType(events);

    // Create an Entity Event Filter Spec to
    // specify the MoRef of the MO to be get events filtered for
    EventFilterSpecByEntity entitySpec = new EventFilterSpecByEntity();
    entitySpec.setEntity(mo.getMOR());
    entitySpec.setRecursion(EventFilterSpecRecursionoption.children);
    // set the entity spec in the EventFilter
    eventFilterSpec.setEntity(entitySpec);

    if (vcenterConnectedTime != null) {
        EventFilterSpecByTime timeSpec = new EventFilterSpecByTime();
        timeSpec.setBeginTime(vcenterConnectedTime);
        // set the time spec in the EventFilter
        eventFilterSpec.setTime(timeSpec);
    }

    // create the EventHistoryCollector to monitor events for a VM
    // and get the ManagedobjectReference of the EventHistoryCollector
    // returned

    EventHistoryCollector collector = eventManager.createCollectorForEvents(eventFilterSpec);
    collector.setCollectorPageSize(1000);
    collectors.add(collector);

    return collector;
}
项目:vijava    文件:QueryEvents.java   
public static void main(String[] args) throws Exception
{
  if(args.length != 3)
  {
    System.out.println("Usage: java QueryEvents " 
        + "<url> <username> <password>");
    return;
  }

  ServiceInstance si = new ServiceInstance(
      new URL(args[0]),args[1],args[2],true);

  // get the latest event and print it out
  EventManager evtMgr = si.getEventManager();
  Event latestEvent = evtMgr.getLatestEvent();
  printEvent(latestEvent);

  // create a filter spec for querying events
  EventFilterSpec efs = new EventFilterSpec();
  // limit to only error and warning
  efs.setType(new String[] {"VmFailedToPowerOnEvent","HostConnectionLostEvent"});
  // limit to error and warning only
  efs.setCategory(new String[] {"error","warning"});

  // limit to the children of root folder
  EventFilterSpecByEntity eFilter = 
    new EventFilterSpecByEntity();
  eFilter.setEntity(si.getRootFolder().getMOR());
  eFilter.setRecursion(
      EventFilterSpecRecursionoption.children);

  // limit to the events happened since a month ago
  EventFilterSpecByTime tFilter = new EventFilterSpecByTime();
  Calendar startTime = si.currentTime();
  startTime.roll(Calendar.MONTH,false);
  tFilter.setBeginTime(startTime);
  efs.setTime(tFilter);
  // limit to the user of "administrator"
  EventFilterSpecByUsername uFilter = 
      new EventFilterSpecByUsername();
  uFilter.setSystemUser(false);
  uFilter.setUserList(new String[] {"administrator"});

  Event[] events = evtMgr.queryEvents(efs);

  // print each of the events
  for(int i=0; events!=null && i<events.length; i++) 
  {
    System.out.println("\nEvent #" + i);
    printEvent(events[i]);
  }

  si.getServerConnection().logout();
}

C语言 function recursion函数递归详解

C语言 function recursion函数递归详解

function recursion(函数递归)

函数递归: 是在 一个 过程 或 函数 在其定义或说明中有 直接 或 间接 调用自身 的一种方法

通常把一个 大型复杂的问题 层层 传化 为一个与 原理相似的 ,规模较小 的问题

递归策略 只需 少量的程序 就可以描述出 解题过程 所需的 多次 重复 计算,大大减少了程序的代码量

递归的中心思想为:

大事化小。

程序一

#include<stdio.h>
int main()
{
    printf("hehe");
    main();//陷入死循环,但因为栈溢出,最后会停下来 == stack overflow - 栈溢出

 任何一次函数调用,它都会向内存申请空间,分为三部分 栈区,堆区,静态区

 栈区 :局部变量,函数的形参

堆区: 动态开辟的内存 - malloc(分配内存) and calloc(动态内存分配并初始化零)

 静态区: 全局变量,static修饰的变量
    return 0;
}

递归的两个必要条件

1,存在限制条件,当满足这个限制条件的时候,递归将不再继续
2.每次递归调用之后越来越接近这个条件

程序一:

#include<stdio.h>
一共调用三次 
1                                                    2                                    3
void print(int n)// n == 123                       void print(int n)n == 12         void print(int n)  m == 1 
{                                           //    {                                 {                                             
    if (n > 9)                             //         if (n > 9)                        if (n > 9)         
    {                                       //        {                                {                                       
        print(n / 10);// 这里再调用 print 函数            print(n / 10);                  print(n / 10);            
    }                                      //         }                                }
    printf("%d ",n%10);   // 最后打印3  //           printf("%d ",n%10); 再打印个2      printf("%d ",n%10); 首先打印 1
}                                          //     }                                 }   
int main()
{
    unsigned int num = 0;
    scanf("%d",&num);//123
    //递归
    print(num);//1 2 3 
    return 0;
}

程序二:

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

写法1(计数器)
int my_strlen(char* str)//str指针变量,需要返回整形
{
    int count = 0;   
    while (*str != ''\0'')
    {
        count++;
        str ++;
    }
    return count;
}
写法2(递归)
int my_strlen(char* str)//str指针变量,需要返回整形
{
    if (*str != ''\0'')
    {
        return 1 + my_strlen(str + 1);
    }
    else
        return 0;
}
int main()
{
    char arr[] = "bit";
    //int len = strlen(arr);
    //printf("%d\n", len);

    //模拟实现一个strlen函数
    int len = my_strlen(arr);
    printf("len = %d\n",len);
    return 0;
}

练习

求n的阶乘

迭代与递归

#include<stdio.h>
1 迭代方式
 int facl(int n)
{
    int i = 0;
    int ret = 1;
    for (i = 1; i <= n; i++)
    {
        ret = ret*i;
    }
    return ret;
}

递归方式
int facl(int n)
{
    if (n <= 1)
    {
        return 1;
    }
    else
        return n*facl(n - 1);
        这里说明一下思维
        假设 我们 要求 10 的阶乘 1x1x2x3x4x5x6x7x8x9x10
        我们的 n 一开始是 10, 10*facl(n-1) ,其实 facl 函数 就是 把 10 减一,递归就好像是循环,循环的目的,就是 得到 10每次减一的结果,直到它等于1,再让其链接起来,
        你可以这么看
        10 *(9 * (8 * (7 * ((6 * (5 * (4 *(3 * (2 * (1 * (1))))))))))
        等价于
        10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 * 1
}
int main()
{
    int n = 0;
    scanf("%d",&n);
    int ret = facl(n);//循环方式
    printf("%d\n",ret);
    return 0;
}


再来道例题

斐波那契函数 1 1 2 3 5 8 13 21
从 第三个数 开始,该数等前面两个数的和。
求第第n个斐波那契函数

#include<stdio.h>
这题用递归效率很低,很多数会重复计算
int fib(int n)
{
    if (n <= 2)
        return 1;
    else
        return fib(n - 1)+fib(n - 2);// 因为 函数 每得到一个数,就需要将得到的数进行分解成 2个 部分
}

2迭代(循环)方式(简单加法)
效率更高
int fib(int n)
{
    int a = 1;
    int b = 1;
    int c = 1;
    while (n>2)// 
    {
        c = a + b;
        a = b;
        b = c;
        n--;
    }
    return c;
}

int main()
{
    int n = 0;
    scanf("%d",&n);
    int ret = fib(n);
    printf("%d\n",ret);
    return 0;
}

在这里插入图片描述

到此这篇关于C语言 function recursion函数递归详解的文章就介绍到这了,更多相关C语言 函数递归内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

您可能感兴趣的文章:
  • 一篇文章带你了解C语言函数递归
  • C语言超细致讲解函数递归

今天关于recursion安全设置security option安全设置选项可设置为的讲解已经结束,谢谢您的阅读,如果想了解更多关于4 Ways to Check the Current PowerShell Version on Your PC、6.递归(Recursion)、com.vmware.vim25.EventFilterSpecRecursionOption的实例源码、C语言 function recursion函数递归详解的相关知识,请在本站搜索。

本文标签: