问题描述
这是编码;
#include< iostream>
使用命名空间std;
int getdata_two(int c [],int startcnt,int endcnt);
main(){
int a [30] = { 0,1,2,3,4,5,6 ...... 29}
int startcnt [6] = {11,11,19,19,24,24},endcnt [6] = {16,16,23,23,27,27},dataval = 68;
if(dataval%2 == 0)
dataval = getdata_one(a,startcnt [0],endcnt [0]);
else if(dataval%2 == 1)
dataval = getdata_two(a,startcnt [1],endcnt [1]);
switch(dataval%2){
case 0:
dataval = getdata_three(a,startcnt [2],endcnt [2]);
休息;
案例1:
dataval = getdata_four(a,startcnt [3],endcnt [3]);
}
int getdata_two(int c [],int startcnt,int endcnt){
int datacnt = endcnt;
while(startcnt< endcnt){
datacnt + = c [ startcnt];
startcnt ++;
}
返回datacnt ;
}
//
1)我的第一个问题,
if [(dataval%2 == 0)
dataval = getdata_one(a,startcnt [0],endcnt [0]);
否则(dataval%2 == 1)
dataval = getdata_two(a,startcnt [1],endcnt [1]);
这是函数调用对吗?现在满足的条件是(dataval%2 == 0),它将调用函数定义---->
int getdata_two(int c [],int startcnt,int endcnt){<
int datacnt = endcnt;
while(startcnt< endcnt){
datacnt + = c [startcnt];
startcnt ++ ;
}
返回datacnt;
}
2)什么是意思是datacnt = endcnt?是传输数组的数量是6还是数组中的内容?
3)FOR ---> ;;虽然(startcnt< endcnt),它试图比较的条件是什么?是数组编号(6
4)执行完毕后功能定义,它将继续操作---->
switch(dataval%2){
case 0:
dataval = getdata_three(a,startcnt [2],endcnt [2]);
break;
case 1:
dataval = getdata_four (a,startcnt [3],endcnt [3]);
}
对吗?它为什么打破了?谢谢你回答我的问题:)
我尝试过:
帮助我们找出编码的路径。 p / s:Sory for bad english
This is the coding;
#include <iostream>
using namespace std;
int getdata_two(int c[],int startcnt, int endcnt);
main(){
int a[30]= {0,1,2,3,4,5,6......29}
int startcnt [6] = {11,11,19,19,24,24}, endcnt[6]={16,16,23,23,27,27},dataval=68;
if (dataval % 2 ==0)
dataval=getdata_one(a,startcnt[0],endcnt[0]);
else if (dataval % 2 ==1)
dataval=getdata_two(a,startcnt[1],endcnt[1]);
switch (dataval % 2){
case 0:
dataval=getdata_three(a,startcnt[2],endcnt[2]);
break;
case 1:
dataval=getdata_four(a,startcnt[3],endcnt[3]);
}
int getdata_two(int c[],int startcnt, int endcnt){
int datacnt=endcnt;
while (startcnt<endcnt){
datacnt+=c[startcnt];
startcnt++;
}
return datacnt;
}
//
1)My first question,
if [(dataval % 2 ==0)
dataval=getdata_one(a,startcnt[0],endcnt[0]);
else if (dataval % 2 ==1)
dataval=getdata_two(a,startcnt[1],endcnt[1]);
this is function call right? Now the condition fulfilled is (dataval % 2 ==0), its gonna call function definition ---->
int getdata_two(int c[],int startcnt, int endcnt){
int datacnt=endcnt;
while (startcnt<endcnt){
datacnt+=c[startcnt];
startcnt++;
}
return datacnt;
}
2) What is meant by datacnt = endcnt? Is it transfer the number of array which is 6 or the content inside the array?
3) FOR --->; while (startcnt < endcnt), whats the condition that its trying to compare to? is it the array number which is (6<6) or the total content inside array startcnt and endcnt which is 108 and 132 respectively?
4) After it carried out the function definition,it will continue the operation which is ---->
switch (dataval % 2){
case 0:
dataval=getdata_three(a,startcnt[2],endcnt[2]);
break;
case 1:
dataval=getdata_four(a,startcnt[3],endcnt[3]);
}
right? Why did it break tho? Thanks for answering my question :)
What I have tried:
Help meeee in to figure out the path that this coding go. p/s : Sory for bad english
推荐答案
- 函数
- 变量和类型
- 比较运算符
- 语句和流控制(循环,
break
声明)
- Functions
- Variables and types
- Comparison operators
- Statements and flow control (loops,
break
statement)
这篇关于有人能帮我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!