问题描述
- C++指针问题 *(primes_i + count_i++) = trail_i;
-
#include <iostream>#include <iomanip>using namespace std;#define maxn 100void main11(){ //const auto maxn = 100; long primes_i[maxn] = { 2 3 6 }; long trail_i = 5; auto count_i = 3; auto found_i = false; do { trail_i += 2; found_i = false; for (int i{}; i < count_i; i++) { found_i = (trail_i % * (primes_i + i)) == 0; if (found_i) break; } if (!found_i) { *(primes_i + count_i++) = trail_i; } } while (count_i < maxn); for (int i{}; i < maxn; i++) { if (i % 5 == 0) { cout << endl; } cout << setw(10) << *(primes_i + i); } cout << endl; system(""pause"");}
其中
*(primes_i + count_i++) = trail_i;
是什么意思
解决方案
primes-i是数组的首地址(指针),与count-i相加表示地址(指针)进行加法运算,也就是获取数组其他元素的地址(指针)。如果count是1,那么primes_i + count_i++的结果就是得到数组的第二个元素的地址(指针),在此句话执行结束之后count再加1,进而继续操作数组下一个元素
那么整个语句的意思就是给long数组中的某个元素进行赋值,结合循环完成对数组所有元素逐个赋值
解决方案二:
?在VPC上装了redhat9不知道改了什么东西后启动时出现了 i8253 count too highresetting的提示开机grub处按e键,选择内核2.4.20-8按e在第一行末端,也就是kernel /vmlinuz-2.4.20-8 ro root=LABEL=/后面加入single即kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ sin......
答案就在这里:i8253 count too high
解决方案三:
这句话又是什么意思
found_i = (trail_i % * (primes_i + i)) == false;
时间: 2024-09-13 08:13:13