Advertisement
derazanother

test 3

Feb 5th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {  
  6.     int n,r,v,i,max=0,min=0,j;
  7.     char str[7][50];
  8.         do{
  9.             printf("How many srting(4-7): ");
  10.             scanf("%d",&n);
  11.            
  12.           }while(n<4||n>7);
  13.           for(i=0;i<n;i++){
  14.             do{
  15.                 printf("String %d",i+1);
  16.                 fflush(stdin);
  17.                 gets(str[i]);
  18.                 r = strlen(str[i]);
  19.               }while(r<0||r>50);
  20.          
  21.           }
  22.                 printf("Output\n");
  23.                 for(i=0;i<n;i++){
  24.                     printf("String %d ",i+1);
  25.                     printf("%s",str[i]);
  26.                     v = strlen(str[i]);
  27.                     printf(" = %d\n",v);
  28.                    
  29.                    }
  30.                 for(i=0;i<n;i++){
  31.                     if(strlen(str[i])>strlen(str[max])){
  32.                      
  33.                     max=i;
  34.                 }
  35.                     if(strlen(str[min])>strlen(str[i]))
  36.                     min=i;
  37.                    
  38.                   }
  39.                   printf("String \"%s\" is longer \n",str[max]);
  40.                   printf("String \"%s\" is shortest \n",str[min]);
  41.                   //j = strlen(str[max]);
  42.                  
  43.                  
  44.                  
  45.                   for(i=strlen(str[max])-1;i>=0;i--){
  46.                     printf("%c",str[max][i]);
  47.                   }
  48.    return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement