#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中文网其它相关文章!
已抢23165个
抢已抢117570个
抢已抢139135个
抢已抢6189个
抢已抢35200个
抢已抢7827个
抢