Gallery

string4.c


#include
#include
void misteri(const char st1[25], char st2[25]) {
int i;
int p = strlen(st1);
char t;
strcpy(st2, st1);
for (i=0; i<=p/2; i++) {
t = st2[i];
st2[i]= st2[p-i-1];
st2[p-i-1]=t;
}
printf("%s %s\n",st1,st2);
}

main()
{
const char st1[125], st2[25];
scanf("%s", &st1);
scanf("%s", &st2);
misteri (st1, st2);
return 0;
}


apa itu strlen?
dia itu buat ngitung banyaknya karakter
kalo strcpy? nah dia buat ngopi bukan ngeteh wuahaha
jadi, kalo diliat di atas si st1 itu di-copy. nah, kopiannya itu namanya st2.

inputnya:
ipb bogor

nanti outputnya jadi:
ipb bpi

jadi, tujuan program ini tuh buat ngebalikin karakter –> “ipb” jadi “bpi”

Advertisements

Leave your comment ! :D

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s