Home > Back-end >  The c language
The c language

Time:06-11

How to do? This problem is

CodePudding user response:

To build an array, and then input, search

CodePudding user response:

The input of the data stored in arrays, when you're looking for input data, an array traversal comparison according to the requirement of the topic,

CodePudding user response:

refer to the second floor weixin_40290083 response:
in the input data stored in arrays, when you're looking for input data, an array traversal comparison according to the requirement of the topic,

Can call out to have a look, I can't

CodePudding user response:

reference 1st floor qq_45798109 response:
built an array, and then input, find

Can play out, I won't ah

CodePudding user response:

Int main ()
{
Int num [20].
Int numTemp;
int i;
Printf (" please enter a number (20), and ends with a 1: ");
Scanf_s (" % d ", & amp; NumTemp);
For (I=0; I & lt; 20 & amp; & NumTemp!=1; I++) {
Num=numTemp [I];
Scanf_s (" % d ", & amp; NumTemp);
}
If (I==20) {
Num [19]=1;
}
The else {
Num [I]=1;
}
Printf (" please enter a number to find: ");
Int findNum;
Scanf_s (" % d ", & amp; FindNum);
Bool findMark=0;
i=0;
While (I & lt; 20 & amp; & Num [I]!=1) {
If (num==findNum [I]) {
Printf (" % d ", I);
FindMark=1;
break;
}
i++;
}
if (! FindMark) {
Printf (" not found ");
}

}

Input data is not checked, there is no requirement, you can add code,

CodePudding user response:

reference 5 floor weixin_40290083 reply:
int main ()
{
Int num [20].
Int numTemp;
int i;
Printf (" please enter a number (20), and ends with a 1: ");
Scanf_s (" % d ", & amp; NumTemp);
For (I=0; I & lt; 20 & amp; & NumTemp!=1; I++) {
Num=numTemp [I];
Scanf_s (" % d ", & amp; NumTemp);
}
If (I==20) {
Num [19]=1;
}
The else {
Num [I]=1;
}
Printf (" please enter a number to find: ");
Int findNum;
Scanf_s (" % d ", & amp; FindNum);
Bool findMark=0;
i=0;
While (I & lt; 20 & amp; & Num [I]!=1) {
If (num==findNum [I]) {
Printf (" % d ", I);
FindMark=1;
break;
}
i++;
}
if (! FindMark) {
Printf (" not found ");
}

}

Input data is not checked, there is no requirement, you can add code implementation,

Ok, go back to the computer and see, thank you!

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related