Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int mas[15] = {1,45,2,56,23,65,322,65,1,32,5,23,6,78,65},search2;
- scanf("%d",&search2);
- for (int i = 0; i < 15; i++)
- {
- if(search2 == mas[i])
- {
- printf("IndexOf: %d \n",i+1);
- break;
- }
- if(i == 14 && search2 != mas[i])
- {
- printf("IndexOf: -1\n");
- }
- }
- for (int i = 14; i > -1; i--)
- {
- if (search2 == mas[i])
- {
- printf("LastIndexOf: %d ",abs(i+1-15));
- break;
- }
- else if(i == 0 && search2 != mas[i])
- {
- printf("LastIndexOf: -1\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement