gpt4 book ai didi

c++ - C++指针,输出

转载 作者:行者123 更新时间:2023-12-02 10:36:31 25 4
gpt4 key购买 nike

#include<iostream>
#include<cmath>
using namespace std;
void main()
{
float x[5] = { 1,2,3,4,5 };
float *zeiger = x + 1;
cout << zeiger << endl;
cout << *(zeiger + 2) << endl;
for (int i = 0; i < 3; i++)
{
zeiger += i;
x[i] = pow(*zeiger, -1);
cout << x[i] << endl;
};
system("PAUSE");
};

大家好。
有人可以告诉我为什么程序最后给出0.2吗?
我了解以前的输出:
地址
4
0,5
0,33

但是为什么要0.2呢?不应该是0.25吗? (对不起,如果我的英语不符合您的喜好。还在学习:))

最佳答案

没关系。现在我明白了。没意识到使用+ = i时齐格将被覆盖。谢谢你们 :)

关于c++ - C++指针,输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60040096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com