下列方法定义中,不正确的是? A:int x(int a,int b){return a*b); B:int x(int a ,int b){return 1.2*(a+b)}; C:float x(int a,int b){return a+b}; D :int x(int a,int b){return a-b};
时间: 2023-03-21 12:03:28 浏览: 30
不正确的方法定义是 A:intx(inta,intb){returna*b);,因为在方法定义中缺少一个右括号,应该为 A:intx(inta,intb){returna*b;}。B、C、D 三个方法定义语法上没有错误。
相关问题
return *(int *)a - *(int *)b;
`return *(int *)a - *(int *)b;` 这是一个C/C++语言中的表达式,它涉及到指针运算。这里解释一下每一部分:
1. `*(int *)a`: 这表示取`a`指向的地址中的值,因为前面有一个星号(*),意味着解引用操作,而`int *`表示`a`是一个指向整数(int)的指针。
2. `*(int *)b`: 类似地,这个表达式取`b`指向的地址中的整数值。
3. `-`: 这个操作符表示减法,即将`a`指向的整数值从`b`指向的整数值中减去。
所以整个表达式的含义是返回两个整数相减的结果。这个表达式通常用于比较或计算两个存储在内存不同位置的整数值。
int max(int a, int b, int c) { int m; m = (a > b) ? a : b; return (m > c) ? m : c; }中,?是什么意思
在这段代码中,问号 ? 是 C 语言中的条件运算符(也被称为三元运算符)。它的作用是根据某个条件的真假来决定返回值是第一个操作数还是第二个操作数。具体语法为:
```
condition ? value_if_true : value_if_false
```
在这个函数中,`m = (a > b) ? a : b;` 表示如果 `a > b` 成立,则 `m` 的值为 `a`,否则 `m` 的值为 `b`。这个条件运算符的作用是在 `a` 和 `b` 中找到最大值,将其赋值给 `m`。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)