为您找到"
main() { int p[8]={11,12,13,14,15,16,17,18},i=0,j=0; while(i++<...
"相关结果约100,000,000个
先要知道i++的意思是先使用i判断完以后再加一;例如本题中先用i==0来判断是否小于7,满足后加一变为1,注意此时if中判断是用p[1]判断,显然p[1]除2余0不满足,同理接住判断即可哦。
@pmg: The '\n' being at the end or the beginning is an output decision. '\n' at the end probably makes more sense, but maybe the it doesn't. Making main an int and having the program return 0 is a change that should be made, of course. -
这道题的正确答案是45, 可我算的是56,我基本明白了,就是有一个地方没明白,我加的是11+13+15+17=56,按答案的意思肯定是没有11,我不明白为什么,i可以取的值是1到7,为什么不能取i=1呢 展开
5 int main() 6 {7 const char * str = "Hello, World!"; 8 cout << str << "\n"; 9 return 0; 10 } 2.2 Hello World II (9 points) 1. for loop: (3 points) 1 #include 2 3 using namespace std; 4 5 int main() 6 {7 int N; 8 cin >> N; 9 for (; N-- > 0;) 10 {11 cout << "Hello, World!\n"; 12 } 13 return 0; 14 } 1
int p[8]={11,12,13,14,15,16,17,18},i=0,j=0简单嘛,我们主要来分析这条语句:while(i++<7) if(p[i]%2) j+=p[i]; 开始是i初始化为0,则while(i++<7 ...
The correct answer is option 1.. Concept: An array is defined as a collection of data items of the same type that are stored in contiguous memory locations.
1st 2D array have {10,11,12,13,14,15,16,17,18} 2nd 2D array have {19,20,21,22,23,24,25,26,27} each 2D array is collection of 1D array. we have 3 one dimensional arrays in one 2D
文章浏览阅读31次。程序的输出结果是 48。 while 循环中,i 的初始值为 0,所以在第一次循环中,i 的值为 1,然后判断 p[1] 是否为奇数,由于 11 是奇数,所以 j 的值加上 11
B[解析] 本题考查的是while语句和if语句的综合应用。程序中while的循环条件是1++<7,由于程序开始时将i初始化为0,而且循环体中没有改变变量i的语句,只有循环条件中i的自增,所以当i从0自增到6时循环的循环体一共被执行了7次,但是在循环体中,i的值为从1到7。
[解析] 在C语言中,数组的下标默认为0,因此数组p的下标范围为:0~7。程序循环过程为:第1次循环i=0,执行循环,并且 i自加,得i=1,因此p[i]为p[1]=12,12%2=0,不执行后面的语句;接着进行第2次循环,此时i=1,小于7执行循环,并且