Advertisement
aunkang

Lab 6-5

Dec 20th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2.   int main()
  3. {
  4.       int positions[50],i,y,count=0;
  5.       char words[100],x;
  6.     gets(words);
  7.     for(i=0;i<=150;i++){
  8.         if(words[i]=='\0'){
  9.             break;
  10.         }
  11.     }
  12.     y = i;
  13.     scanf("%c",&x);
  14.     for(i=0;i<=y;i++){
  15.         if(x==words[i] || x-32==words[i]){
  16.             count += 1;
  17.             positions[count] = i+1;
  18.         }
  19.     }
  20.     printf("There is/are %d \"%c\" in the above sentences.\n",count,x);
  21.     printf("Position: ");
  22.     for(i=0;i<=count-1;i++){
  23.         printf("%d",positions[i+1]);
  24.         if(i<count-1){
  25.             printf("%c ",',');
  26.         }
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement