Advertisement
andruhovski

prog0109-demo

Sep 10th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. // ConsoleApplication24.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9.     int a[8]={10,3,5,6,20,44,66,8};
  10.     int x=10,i;
  11.     bool isFound=false;
  12.     //for ( i=0;i<8;i++)
  13.     //  if (a[i]==x) {
  14.     //      isFound=true;
  15.     //      break;
  16.     //  }
  17.     int *pos=a, *end=a+9;
  18.     do
  19.     {
  20.         if (*pos==x)
  21.         {
  22.             isFound=true;
  23.             break;
  24.         }
  25.     } while (++pos<end);
  26.  
  27.     if (isFound)
  28.         printf("Yes! pos=%d\n",pos-a);
  29.     else
  30.         printf("No!\n");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement