Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int n,r,v,i,max=0,min=0,j;
- char str[7][50];
- do{
- printf("How many srting(4-7): ");
- scanf("%d",&n);
- }while(n<4||n>7);
- for(i=0;i<n;i++){
- do{
- printf("String %d",i+1);
- fflush(stdin);
- gets(str[i]);
- r = strlen(str[i]);
- }while(r<0||r>50);
- }
- printf("Output\n");
- for(i=0;i<n;i++){
- printf("String %d ",i+1);
- printf("%s",str[i]);
- v = strlen(str[i]);
- printf(" = %d\n",v);
- }
- for(i=0;i<n;i++){
- if(strlen(str[i])>strlen(str[max])){
- max=i;
- }
- if(strlen(str[min])>strlen(str[i]))
- min=i;
- }
- printf("String \"%s\" is longer \n",str[max]);
- printf("String \"%s\" is shortest \n",str[min]);
- //j = strlen(str[max]);
- for(i=strlen(str[max])-1;i>=0;i--){
- printf("%c",str[max][i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement