Last active
December 27, 2017 19:34
-
-
Save hamikaya/e423fc2f7583adb6754412e3781c3376 to your computer and use it in GitHub Desktop.
Algoritma Programlamaya Giriş
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
package algoritma; | |
import java.util.*; | |
public class ikinci_soru { | |
public static void main(String[] args) { | |
Scanner giris = new Scanner(System.in); | |
System.out.print("Cümle Girin:"); | |
String cumle = giris.nextLine(); | |
int harf_sayi = cumle.length(); | |
System.out.print("Girdiğiniz cümlenin tersten yazılışı: "); | |
for (int i = harf_sayi-1; i>=0; i--) { | |
System.out.print(cumle.charAt(i)); | |
} | |
int kelime_sayisi=0; | |
for (int i=0; i<cumle.length(); i++) { | |
if (cumle.charAt(i)==' ') | |
kelime_sayisi++; | |
} | |
String cumle1= cumle.replace(" ",""); | |
int h_s = cumle1.length(); | |
System.out.println("\nGirdiğiniz cümle "+h_s+" karakter içeriyor."); | |
String cumle2[] = cumle.split(" "); | |
for (int cu = 0; cu<=kelime_sayisi ; cu++) { | |
System.out.println(cu+1+". kelime: "+cumle2[cu]); | |
} | |
String alfabe_karakter = "0123456789ABCDEFGHIİJKLMNOÖPQRSŞTUÜVWXYZabcdefghıijklmnoöpqrsştuüvwxyz.?"; | |
int[] alfabe_karakter_dizi = new int[alfabe_karakter.length()]; | |
for (int i = 0; i < cumle.length(); i++) { | |
int index = alfabe_karakter.indexOf(cumle.charAt(i)); | |
if (index < 0) { | |
continue; | |
} | |
alfabe_karakter_dizi[index]++; | |
} | |
for (int i = 0; i < alfabe_karakter_dizi.length; i++) { | |
if (alfabe_karakter_dizi[i] < 1) { | |
continue; | |
} | |
System.out.println(alfabe_karakter.charAt(i)+" harfi "+alfabe_karakter_dizi[i]+" kez tekrar etti."); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment