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)
注意......我在这里已经阅读了相关的问题,但没有一个与我的问题有关......
下面的代码用于计算每次字符串'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) 我正在为即将到来的编码面试练习,这是我的一个练习题,也是我离我有多远.
我该如何改进该计划以及您的建议.
此外,是否有任何城市可以帮助提高我的编码技能.
题;
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)