Advertisement
cd62131

find

Mar 13th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void find(char **ADS, int NUM_ADS) {
  5.   int i;
  6.   puts("検索結果:");
  7.   puts("-------------------------");
  8.   for (i = 0; i < NUM_ADS; i++) {
  9.     if (strstr(ADS[i], "sports") && !strstr(ADS[i], "bieber")) {
  10.       printf("%s\n", ADS[i]);
  11.     }
  12.   }
  13.   puts("-------------------------");
  14. }
  15.  
  16. int main(void) {
  17.   char *ADS[] = {
  18.     "William: SBM GSOH likes sports, TV, dining",
  19.     "Matt: DWM NS likes art,movies, theater",
  20.     "Luis: SLM ND likes books, theater, art",
  21.     "Mike: DWM DS likes trucks, sports and bieber",
  22.     "Josh: SJM likes sports, movies and theater",
  23.     "Jed: DEM likes theater, books and dining"
  24.   };
  25.   int NUM_ADS = sizeof(ADS) / sizeof(char **);
  26.   find(ADS, NUM_ADS);
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement