Home > Back-end >  C the number of multiple input multiple loops
C the number of multiple input multiple loops

Time:09-23

The question is as follows:
Sequence input multiple group, each group of input number N (number in 1-99), legal, return true said false illegal
1. A digit and two digits appear alternately, legal
2. The beginning and end is a digit, middle is double digits, legal
3. The beginning of the end is double digits, is between the single digits, legal
This topic I don't know how to start, there are two big problems:
1. Don't know how to control loop (EOF not like row), each time the number of input uncertainty N in one line, then press enter on the output of true or false, after the output to the next line continue to input the number N
2. The judge, I tend to be int f=0 means illegal, verify again when legal to f=1, when validation, in case of the if condition statement there are for I feel very confusion
Have a big help to have a look at it ~ if can WeChat chat a little better, problem seems a little bit smaller than ha ha ha ~
Right now I code then enter a set of inputs to collapse,,,
 # include 
{int danshu (int a)
Int f=0;
If (a> 0& & A<=9) {
f=1;
}
Return the f;//enter a digit returns 1, because the input only in 1 ` 99, so the default for the input double-digit returns 0
}
Int main () {
While (1) {//control sequence of loop
Int result=0, I=0, a, [1000].
While (the scanf (" % d ", a [I])) {
i++;//a set of input the number I
}
for(int j=0; jIf (danshu (a [0]) {


} else {

}
For (int k=j + 1; KIf (danshu (a) [j] & amp; & ! Danshu (a) [k]) {
result=1;//result==1 legal
tagbreak;
}
If (result==1) break;
}
If (result==1) break;
}
If (result==0 & amp; & Danshu (a [0]) & amp; & Danshu (a) [I - 1]) {//the second legal case
Int r=1;
for(int j=1; jIf (danshu (a) [j]) {
R=0;
break;
}
}
If (r==1) {
result=1;
}
} else if (result==0 & amp; & ! Danshu (a [0]) & amp; & ! Danshu (a) [I - 1]) {
Int r=1;
for(int j=1; jif(! Danshu (a) [j]) {
R=0;
break;
}
}
If (r==1) {
result=1;
}
}
If (result==1) {
Printf (" true ");
} else {
Printf (" false ");
}
}
return 0;
}

CodePudding user response:

Will have a big
  • Related