C Ödev

  1. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Seastar
    Seastar's avatar
    Kayıt Tarihi: 08/Ekim/2005
    Erkek

    Selam hocalar. kız arkadaşımın c ödevi var da ben tbtye güvenip hallederim demiştim :) saat 12 ye kadar yapılması gerekiyomuş. bi el atın lütfen.

    kac soru yapabiliyosanız yapın o da yeter. bi soru bi sorudur :)

    bi de ingilizce olmadığı için çeviri yapamadım birebir kopyaladım kusura bakmayın.

     

    1. (20 pts.) Write a C program that reads a string from keyboard and converts lower-case
    letters to upper-case, and upper-case letters to lower-case. You have to use a pointer
    while moving on the string and case converting must be on the same string.

    Enter a string:
    She Sells Sea Shells By The Seashore.
    Case converting yields:
    sHE sELLS sEA sHELLS bY tHE sEASHORE.


    2. (20 pts.) Write a program that counts and lists the number of all English letters in a
    given string. Your program should be case-insensitive, i.e. lower-case and upper-case
    letters should be counted together. You have to use a pointer while moving on the
    string.
    Enter a string:
    She Sells Sea Shells By The Seashore.
    Number of each letter in the string:
    A : 2
    B : 1
    E : 7
    H : 4
    L : 4
    O : 1
    R : 1
    S : 8
    T : 1
    Y : 1

    3. (20 pts.) Write a C program that finds the sequence of letters “foo” in a string given by
    keyboard, and replaces it by the letters “bars”. You have to use a pointer while moving
    on the string.

    4. (15 pts.) Like the first question of the second homework, read N integers from
    keyboard and rewrite them in reverse order. However, using indices is prohibited, you
    have to use pointers. If you use any indices, like arr[i], then you’ll be graded as zero
    from this question.

    5. (15 pts.) Write a C program that reads N integers from keyboard and finds the sequence
    of integers “9-1-1” in the array and replaces them by the sequence “1-1-2”. You have
    to use a pointer while moving on the array.
    Note: You’ll get the remaining 10 points from your comments and indentation.

  2. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Ekerci
    Ekerci's avatar
    Kayıt Tarihi: 14/Ocak/2010
    Erkek

    hocam kolaymıs gecen sene olsaydı yapardım.simdi c aklımdan tamamen cıkmıs durumda..uplayalım bari


    Konu ID: 112846 Konuyu Acan : Ekerci Konu Başlığı : Tahribatın en sevdiği adam ? Silinme Sebebi : 3 sayfadır takip ediyorum beni seven kimse çıkmadı. alacağınız olsun müridler
  3. KısayolKısayol reportŞikayet pmÖzel Mesaj
    ferriere
    ferriere's avatar
    Kayıt Tarihi: 13/Ekim/2012
    Erkek

    hocam bu 2. sorunun hemen hemen aynısı sadece q girince sonuç veriyodu bizim 1. sınıf ödeviydi switch in içindeki case leri tüm harflere uyarlarsanız tam istediğiniz gibi çalışır

     

    #include <stdio.h>
    
    main()
    {
    int a=0,b=0,c=0,other=0;
    char karakter;
    	while((karakter=getchar()) != 'q'){
    		
    		switch(karakter){
    			case 'a': a += 1;break;
    			case 'b': b += 1;break;
    			case 'c': c += 1;break;
    			default: other += 1;
    		}
    	}
    	printf("a:%d\n b:%d\n c:%d\n other:%d\n",a,b,c,other);
    }
  4. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Tugberk
    Tugberk's avatar
    Kayıt Tarihi: 04/Ekim/2009
    Erkek

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

    1)

    #include <stdio.h>
    #include <ctype.h>
    
    int main()
    {
    	char text[256] = {0};
    	char *ptr = text;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	
    	do {
    		if (islower(*ptr)) {
    			*ptr = toupper(*ptr);
    		}
    		else {
    			*ptr = tolower(*ptr);
    		}
    	} while(*++ptr);
    	
    	printf("Case converting yields:\n%s", text);
    	return 0;
    }

    2)

    #include <stdio.h>
    #include <ctype.h>
    
    int main()
    {
    	int i, counts[256] = {0};
    	char text[256] = {0};
    	char *ptr = text;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	
    	do {
    		if (isalpha(*ptr)) {
    			*ptr = toupper(*ptr);
    			counts[*ptr]++;
    		}
    	} while(*++ptr);
    	
    	printf("Number of each letter in the string:\n");
    	
    	for (i=0; i<256; i++) {
    		if (counts[i]) {
    			printf("%c : %d\n", i, counts[i]);
    		}
    	}
    	return 0;
    }

    3)

    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    
    int main()
    {
    	char text[256] = {0}, shadow[512] = {0};
    	char *ptrText = text, *ptrShadow = shadow;
    	int  i, len = 0;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	len = strlen(text);
    	
    	for (i=0; i<len-2; i++)
    	{
    		if (*ptrText == 'f' && *(ptrText+1) == 'o' && *(ptrText+2) == 'o')
    		{
    			strcat(shadow, "bars");
    			ptrText+=3;
    			ptrShadow+=4;
    		}
    		else {
    			*ptrShadow++ = *ptrText++;
    		}
    	}
    	
    	printf("Replaced text:\n%s", shadow);
    	return 0;
    }
  5. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Bosluk
    Bosluk's avatar
    Kayıt Tarihi: 11/Kasım/2007
    Erkek
    Tugberk bunu yazdı

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

    1)

    #include <stdio.h>
    #include <ctype.h>
    
    int main()
    {
    	char text[256] = {0};
    	char *ptr = text;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	
    	do {
    		if (islower(*ptr)) {
    			*ptr = toupper(*ptr);
    		}
    		else {
    			*ptr = tolower(*ptr);
    		}
    	} while(*++ptr);
    	
    	printf("Case converting yields:\n%s", text);
    	return 0;
    }

    2)

    #include <stdio.h>
    #include <ctype.h>
    
    int main()
    {
    	int i, counts[256] = {0};
    	char text[256] = {0};
    	char *ptr = text;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	
    	do {
    		if (isalpha(*ptr)) {
    			*ptr = toupper(*ptr);
    			counts[*ptr]++;
    		}
    	} while(*++ptr);
    	
    	printf("Number of each letter in the string:\n");
    	
    	for (i=0; i<256; i++) {
    		if (counts[i]) {
    			printf("%c : %d\n", i, counts[i]);
    		}
    	}
    	return 0;
    }

    3)

    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    
    int main()
    {
    	char text[256] = {0}, shadow[512] = {0};
    	char *ptrText = text, *ptrShadow = shadow;
    	int  i, len = 0;
    	
    	printf("Enter a string:\n");
    	fgets(text, sizeof(text)-1, stdin);
    	len = strlen(text);
    	
    	for (i=0; i<len-2; i++)
    	{
    		if (*ptrText == 'f' && *(ptrText+1) == 'o' && *(ptrText+2) == 'o')
    		{
    			strcat(shadow, "bars");
    			ptrText+=3;
    			ptrShadow+=4;
    		}
    		else {
    			*ptrShadow++ = *ptrText++;
    		}
    	}
    	
    	printf("Replaced text:\n%s", shadow);
    	return 0;
    }

    Hayattan soguma sebebi yeminle


    ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
  6. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Seastar
    Seastar's avatar
    Kayıt Tarihi: 08/Ekim/2005
    Erkek
    Tugberk bunu yazdı

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

     

     
     

    hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv

  7. KısayolKısayol reportŞikayet pmÖzel Mesaj
    manyaki
    manyaki's avatar
    Kayıt Tarihi: 27/Temmuz/2005
    Erkek
    Seastar bunu yazdı
    Tugberk bunu yazdı

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

     

     
     

    hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv

    #include <conio.h> ve return den önce getch();


    since 2005 // tbt
  8. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Seastar
    Seastar's avatar
    Kayıt Tarihi: 08/Ekim/2005
    Erkek
    manyaki bunu yazdı
    Seastar bunu yazdı
    Tugberk bunu yazdı

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

     

     
     

    hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv

    #include <conio.h> ve return den önce getch();

    12 ye kadardı pek vakit olmadı öyle gönderdim. çok fazla bi puan kırmaz sanırsam 

  9. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Bosluk
    Bosluk's avatar
    Kayıt Tarihi: 11/Kasım/2007
    Erkek
    Seastar bunu yazdı
    manyaki bunu yazdı
    Seastar bunu yazdı
    Tugberk bunu yazdı

    ilk üç sorunun cevabı, 60 alsın yeter :) normalde ödev yapmam ama farklı yollardan (en kısa yoldan) çözmeye çalıştım.

     

     
     

    hocam aynısını kopyaladım gonderdim. programı çalıştı ama ekranda göstermedi. çalıştığı gibi kapandı. fazla kurcalamaya vakitte yoktu öylece gonderdim. cok saol hocam eyv

    #include <conio.h> ve return den önce getch();

    12 ye kadardı pek vakit olmadı öyle gönderdim. çok fazla bi puan kırmaz sanırsam 

    algoritmaya baksın yeter sktr et cıktısını :)


    ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
  10. KısayolKısayol reportŞikayet pmÖzel Mesaj
    ferriere
    ferriere's avatar
    Kayıt Tarihi: 13/Ekim/2012
    Erkek

    devc++ ta çalıştırdıysa

    system("pause"); 

    return 0;

    yazarsa en sona ekran kalır

    saat 12 yi geçti ama faydasını görür ilerde

Toplam Hit: 1262 Toplam Mesaj: 10