Lab6-3 3Checkpoint+Homework

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int i,len;
void replaceStr(char str[],char c1, char c2)
{
     len=strlen(str);
     for(i=0;i<len;i++)
                       if(str[i]==c1)
                                       printf("%c",c2);
                       else printf("%c",str[i]);
                       printf("\n");
     }
 int main()
 {int count;
 char ch1,c1,c2;
 char chk3[5][4][40];
 char str1[50], str2[50];
 while(1)
 {
 printf("Enter the first string : ");
 scanf("%s",str1); //fflush(stdin);
 printf("Enter the second string : ");
 scanf("%s",str2); //fflush(stdin);
if(strcmp(str1,str2)<0)
printf("\"%s\" comes before \"%s\" \n------\n",str1,str2);
else printf("\"%s\" comes after \"%s\" \n------\n",str1,str2);
printf("\nCheck Point2\n");
printf("Enter 2 Charactors to replace in First String ex. a->A\n");
scanf("%c %c %c",&c1,&c1,&c2);
replaceStr(str1,c1,c2);
printf("\n---------\n");
printf("\nCheck point3\n");
for(i=0;i<5;i++)
                {printf("Enter Name surname Province Year:");
                scanf("%s %s %s %s",chk3[i][0],chk3[i][1],chk3[i][2],chk3[i][3]);
}
for(i=0;i<5;i++)
                {
                printf("%s %s %s %s\n",chk3[i][0],chk3[i][1],chk3[i][2],chk3[i][3]);
}/*
printf("\nHomework 1\n");
for(count=i=0;i<len;i++)
                  switch(str1[i])
                  {case 'a':case 'A':case'e':case'E':case'i':case'I':case'o':case'O':case'u':case'U': count++;}
printf("%s has %d vowel",str1,count);
printf("\nHomework 2\n");
for(;len!=-1;len--)
printf("%c",str1[len]);

printf("\nHomework 3\n");
len=strlen(str1);
for(i=0;i<len/2;i++)
if(str1[i]!=str1[len-1])break;
if(i==len/2)
printf("%s is parimdrome",str1);
else                   printf("%s is not parimdrome",str1);
*/
}
system("PAUSE");
 return 0;
}

Popular posts from this blog

เทคนิค ชนะ เกมเศรษฐี 14 ตารวด!!! ( Let's get Rich )

Using Google Chrome Inspect Element to Analyze the website

Easy way to download whole youtube play list and convert them to mp3