PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

在C语言中的布尔数组谜题

WBOY
WBOY 转载
2023-08-29 15:05:05 807浏览

在C语言中的布尔数组谜题

  • 允许的操作是补集,其他操作不允许。
  • 不允许使用循环和条件语句。
  • 也不允许直接赋值。
  • 解决布尔数组谜题的程序

    #include <iostream>
    using namespace std;
    void makeZero(int a[2]) {
       a[ a[1] ] = a[ !a[1] ];
    }
    int main() {
       int a[] = {1, 0};
       makeZero(a);
       cout<<"arr[0] = "<<a[0]<<endl;
       cout<<"arr[1] = "<<a[1];
       return 0;
    }

    输出

    arr[0] = 0
    arr[1] = 0
    You can use other ways too. Like this one which does not require the negation operation.
    a[ a[1] ] = a[ a[0] ]

    以上就是在C语言中的布尔数组谜题的详细内容,更多请关注php中文网其它相关文章!

    声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除