#include <stdio.h>int main(){ int a, b, c; a = 5; c = ++a; b = ++c, c++, ++a, a++; b += a++ +
下面代码的结果是:( )
#include <stdio.h> int main() {int a, b, c;a = 5;c = ++a;b = ++c, c++, ++a, a++;b += a++ + c;printf("a = %d b = %d c = %d\n:", a, b, c);return 0; }
作业内容
A.a = 8 b = 23 c = 8
B.a = 9 b= 23 c = 8
C.a = 9 b = 25 c = 8
D.a = 9 b = 24 c = 8
++运算符:分为前置++和后置++,
前置++:先加1,后使用,即先使用变量中内容,然后给结果加1
后置++:先使用变量中内容,整个表达式结束时,给变量加1
逗号表达式,取最后一个表达式的值。
#include <stdio.h> |
|
int main() |
|
{ |
|
int a, b, c; |
|
a = 5; |
|
c = ++a;// ++a:加给a+1,结果为6,用加完之后的结果给c赋值,因此:a = 6 c = 6 |
|
b = ++c, c++, ++a, a++; |
|
// 逗号表达式的优先级,最低,这里先算b=++c, b得到的是++c后的结果,b是7 |
|
// b=++c 和后边的构成逗号表达式,依次从左向右计算的。 |
|
// 表达式结束时,c++和,++a,a++会给a+2,给c加1,此时c:8,a:8,b:7 |
|
b += a++ + c; // a先和c加,结果为16,在加上b的值7,比的结果为23,最后给a加1,a的值为9 |
|
printf("a = %d b = %d c = %d\n:", a, b, c); // a:9, b:23, c:8 |
|
return 0; |
|
} |
#include <stdio.h>int main(){ int a, b, c; a = 5; c = ++a; b = ++c, c++, ++a, a++; b += a++ +相关推荐
- 下列程序的运行结果是 #include <stdio.h> void main() { int x = 10, y = 20, z = 30;
1.直接运行程序得出结果 #include <stdio.h>void main() {int x = 10, y = 20, z = 30;printf("%d %d %d % ...
- c语言switch虚线,有以下程序:include<stdio.h>main(){int c;while((c=getchar())!='\n')switch(c-'2'){case 1:pu...
有以下程序:include<stdio.h>main(){int c:while((c=getchar())!='\n')switch(c-'2'){case 1:pu 更多相关问题 双代 ...
- #include<stdio.h>int main(){ int QQ_num;//定义一个名为QQ_num的变量存放QQ号 char pet_name[10];//定义一个名为pet_name
#include<stdio.h> int main(){int QQ_num;//定义一个名为QQ_num的变量存放QQ号char pet_name[10];//定义一个名为pet_na ...
- 4.根据提示,完成下面的程序。#include<stdio.h>typedef struct date {int year;int month;int day;} Date;void
4.根据提示,完成下面的程序. #include<stdio.h> typedef struct date { int year; int month; int day; } Date; ...
- 5-2交换实数下面的程序,输入两个实数,交换后输出。请在空白处填写适当内容完成此程序。#include <stdio.h>void RealSwap(double *x, doubl
5-2 交换实数 下面的程序,输入两个实数,交换后输出. 请在空白处填写适当内容完成此程序. #include <stdio.h> void RealSwap(double *x, dou ...
- C语言基础-#include<stdio.h>
#include<stdio.h> 告诉编译器把stdio.h中的内容包含在当前程序中. stdio.h是c编译器软件包的标准部分,它提供键盘输入和屏幕输出的支持.
- c语言编程 开头的#include <stdio.h>是什么意思?
#是预处理指令 include 是"包含"的意思 #include " XX" 或者 #include ,意思是将"XX"或者中的文件引用到 ...
- C语言学习纯纯小白-1,C语言代码开头为什么要有#include <stdio.h>
# #include <stdio.h>是什么? 1,#include <stdio.h>是什么? 首先,C++/C程序通常由头文件(header files)和定义文件(de ...
- #include<stdio.h>怎么理解,stdio.h是什么头文件,是不是每个C语言程序都要加?
include 称为文件包含命令,其意义是把尖括号""或引号<>内指定的文件包含到本程序中,成为本程序的一部分.被包含的文件通常是由系统提供的,其扩展名为.h ...
最新文章
- Java yield详解_Java 中的 yield 关键字
- CTF--base64编码过程中隐藏信息解密脚本
- 爬虫学习--豆瓣top250
- php7安装xhprof,PHP 7.1安装xhprof进行性能分析的介绍
- 仓库货位卡标识牌_仓库货架能解决传统仓储的哪些问题?
- IDEA下SSM项目搭建的基本操作
- codeforce 460B Little Dima and Equation
- EPUB电子书专用阅读软件
- IDEA 2018 破解
- 读芯术python讲得怎么样_最读网 - 看是用眼,读是用心!
- python aic准则_赤池信息准则AIC,BIC
- VS2010 保护视力 背景色设置
- 标签thead与th的区别
- 搭建rtmp直播流服务之1:使用nginx搭建rtmp直播流服务器(nginx-rtmp模块的安装以及rtmp直播流配置)
- 数据结构 | 算法中的卡特兰数的应用
- 下载logisim时显示“系统找不到指定路径”的解决办法!!!!
- 练习- Java顺序结构综合练习二之温度换算
- 闲谈IPv6-没有选项胜有选项的TLV
- mysql中的包含与被包含
- 34岁王晓松的成绩单:新城控股收入股价双增,毛利率骤降9%