Advertisement
Pavle_nis

Nizovi stirngova 2

Apr 6th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. // Nizovi Stringova 2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdio.h>
  6. #include <string.h>
  7. int main()
  8. {
  9.     char prez[10][30];
  10.     int i, s = 0, length = 0, br = 0, p = 0;
  11.     for (i = 0; i < 5; i++)
  12.         scanf("%s", prez[i]);
  13.    
  14.     printf("Prezimena koja se zavrsavaju sa 'ic' su: \n");
  15.     for (i = 0; i < 5; i++)
  16.     {
  17.         length = strlen(prez[i]);
  18.         s = length - 2;
  19.         p = length - 1;
  20.  
  21.         if (prez[i][s] == 'i' && prez[i][p] == 'c' || prez[i][s] == 'I' && prez[i][p] == 'C')
  22.         {
  23.             printf("%s\n", prez[i]);
  24.             br++;
  25.         }
  26.     }
  27.     printf("i ima ih: \n%d", br);
  28.  
  29.     getch();
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement