小编Ati*_*uke的帖子

如何获取const char指针的大小

const char *array[] = {"ax","bo","cf"};
Run Code Online (Sandbox Code Playgroud)

试着

printf("size of array = %lu\n", sizeof(const char*));

result != 3
Run Code Online (Sandbox Code Playgroud)

printf("size of array = %lu\n", sizeof(array));
result != **DESIRED ANSWER** = 4
Run Code Online (Sandbox Code Playgroud)

注意......我在这里已经阅读了相关的问题,但没有一个与我的问题有关......

c arrays pointers sizeof

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

如何在不使用s循环的情况下对字符串进行多次计数

下面的代码用于计算每次字符串'x'出现在字符串中但它只计算一次..

我不想使用循环.

public class recursionJava

{

   public static void main(String args[])

   {

      String names = "xxhixx";

      int result = number(names);
      System.out.println("number of x: " + result);
   }

   public static int number (String name)
   {

      int index = 0, result = 0;

      if(name.charAt(index) == 'x')
      {
         result++;
      }
      else
      {
         result = result;
      }
            index++;

      if (name.trim().length() != 0)
      {
        number(name);
      }
      return result;
   }
}
Run Code Online (Sandbox Code Playgroud)

java

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

如何改进代码以返回不成对的元素

我正在为即将到来的编码面试练习,这是我的一个练习题,也是我离我有多远.

我该如何改进该计划以及您的建议.

此外,是否有任何城市可以帮助提高我的编码技能.

题;

    A non-empty zero-indexed array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.

    For example, in array A such that:

      A[0] = 9  A[1] = 3  A[2] = 9
      A[3] = 3  A[4] = 9  A[5] = 7
      A[6] = 9
    the elements at indexes …
Run Code Online (Sandbox Code Playgroud)

java performance

-1
推荐指数
2
解决办法
3356
查看次数

标签 统计

java ×2

arrays ×1

c ×1

performance ×1

pointers ×1

sizeof ×1