Created
November 1, 2010 22:49
-
-
Save gdemir/659014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
int main(void) { | |
int c, state = 1; | |
for ( ; ; ) { | |
c = getchar(); | |
if (c == EOF) break; | |
switch (state) { | |
case 1: | |
if (isalpha(c)) { | |
putchar(toupper(c)); | |
state = 2; | |
} else putchar(c); | |
break; | |
case 2: | |
if (!isalpha(c)) state = 1; | |
putchar(c); | |
break; | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/python | |
#-*- coding:utf-8 -*- | |
from string import upper | |
def ws(c): | |
return c == ' ' or c == '\t' or c == '\n' | |
def ilk_harf_buyult(sectence): | |
state = False | |
new = "" | |
for chr in sectence: | |
if not ws(chr) and not state: # kelimeye giriş yapıyorsam. | |
new += upper(chr) | |
state = True | |
elif not ws(chr) and state: # kelime içindeysem. | |
new += chr | |
elif ws(chr): # kelime dışındaysam. | |
new += chr | |
state = False | |
return new | |
# DIKKAT! tüm ihtimalleri deneyelim | |
print ilk_harf_buyult("merhaba dunya") # arada boşluk | |
print ilk_harf_buyult("merhaba dunya") # arada tab | |
print ilk_harf_buyult("merhaba \ndunya") # arada yeni satır | |
print ilk_harf_buyult(" merhaba dunya") # en başta boşluk | |
print ilk_harf_buyult(" merhaba dunya") # en başta tab | |
print ilk_harf_buyult("\nmerhaba dunya") # en başta yeni satır |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
int main(void) { | |
int c, state = 1; | |
while ((c = getchar()) != EOF ) { | |
switch (state) { | |
case 1: | |
if (isalpha(c)) { | |
putchar(toupper(c)); | |
state = 2;/* Bundan sonra gelecek karakterler küçük olmalı*/ | |
} else | |
putchar(c);/*rakamsa direkt yaz acıma*/ | |
break; | |
case 2: | |
if (!isalpha(c)) | |
state = 1;/*rakam ise state = 1 yap bundan kelimi baş harfi büyüklüğü için*/ | |
putchar(c); | |
break; | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
#define out 0 | |
#define in 1 | |
// ör girdiler : | |
// ali veli | |
// ali veli | |
int main(void) { | |
// cümle dışında diye başlayalım | |
int c, state = out; | |
// ctrl + D yana kadar(EOF) karakter alalım | |
while ((c = getchar()) != EOF ) { | |
// gelen karakterse ve cümle dışındaysak ekrana büyük basalım. | |
// ve cümle içine geçelim. (state = in) | |
if (isalpha(c) && state == out) { | |
putchar(toupper(c)); | |
state = in; // Bundan sonra gelecek karakterler küçük olmalı kelime içindeyim. | |
} | |
// gelen karakterse ve cümle içindeysem ekrana küçük basalım. | |
else if (isalpha(c) && state == in ) { | |
putchar(c); // kelime içinde ve harf ise direkt yaz | |
} | |
// gelen karakter değilse cümle dışında düşünelim | |
else if (!isalpha(c)) { | |
putchar(c); | |
state = out; // rakam ise state = out yap, bundan kelime baş harfi büyüklüğü için | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment