当前位置:网站首页>++ problems in C language
++ problems in C language
2022-06-12 09:05:00 【Record dada I】
I have a very interesting question today , After reading it, I think it is very meaningful , So record it , Prevent everyone from stepping on the pit .
The grammar problem of the original text is to ask the final apd What is the value of .
#include<iostream>
using namespace std;
int main()
{
int sum=5,apd=5;
apd = sum++;
apd++;
++apd;
cout<<apd<<sum;
return 0;
}
The problem lies in apd=sum++ On ;
apd=sum++; This statement will be executed first apd=sum; Immediate speaking sum The value is assigned to apd, And then execute sum++;
So the output value apd=7,sum=6;
int sum=5;
sum=sum++;
cout<<sum;
sum=sum++; No matter how many times you cycle , The end result is 5;
#include<iostream>
using namespace std;
int main()
{
int sum=5;
for(int i=0;i<5;i++)
{
sum=sum++;
}
cout<<sum++;
cout<<sum;
return 0;
}
Output after cycling sum by 5, Then the output sum++ It's also 5;
final sum by 6;
as a result of sum++ Take effect in the next statement ,sum++ Always loop assign to sum, This causes the values in memory to be overwritten in a loop , So it's always been 5;
边栏推荐
- 重启Kubernetes Pod的几种方式
- RuntimeError:Input and parameter tensors are not at the same device, found input tensor at cuda:0 an
- Detailed explanation of iSCSI (V) -- actual operation of iSCSI client configuration
- 网页中加载二次元3D虚拟主播源码(1:项目介绍和源码)
- Problems that cannot be resolved by tar command
- Description of string
- Construction of memcached cache service under Linux:
- MySQL learning record - II. MySQL create table command
- mySql学习记录——二、mySql建表命令
- Convert spaces to < br / > newline labels
猜你喜欢

mySql学习记录——二、mySql建表命令

网页中加载二次元3D虚拟主播源码(1:项目介绍和源码)

Building a cluster: and replacing with error

Background color translucent

Background fixing effect

最少换乘次数

Background location case II

《MATLAB 神經網絡43個案例分析》:第7章 RBF網絡的回歸--非線性函數回歸的實現

Description of string

Does database and table splitting cause reading diffusion problems? How to solve it?
随机推荐
Xshell startup encountered "unable to continue code execution because mfc110.dll cannot be found"
Domain name mapping to specified IP
Exists usage in SQL
2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
Chapter 8 - two basic problems of data processing
Diff prime pairs
Machine learning notes - circular neural network memo list
第三章 寄存器 (内存访问)
(十二)交互组件Selectable
Random acquisition of 4-digit non repeated verification code
解决當打開Unity時 提示項目已經打開,而自己之前並沒有打開過(可能之前异常關閉)的問題
Sword finger offer:[day 8 dynamic planning (simple)] --- > frog jumping on steps
Node sample background setup
第七章-更灵活定位内存地址
第四章-第一个程序
Composition of box model
【字符集七】汉字的宽字符码和多字节码分别是多少
Inheritance of row height
POI library update excel picture
域名映射到指定IP