''Program wypisuje ilosc powtarzania sie litery w podanym wyrazie i wypisuje, na ktorym miejscu litera wystepuje po raz pierwszy''

#pragma hdrstop

#pragma argsused

#include<stdio.h>

  main()

{

char name[20],litera;

int numer,start;

puts("Podaj nazwe:");

gets(name);

puts("Podaj litere:");

litera=getchar();

fun(name,litera,&numer,&start);

printf("nZnak '%c' wystepuje w nazwie %s %d razyn",litera ,name,numer);

printf("Pierwsze wystapienie jest an pozycji %d",start);

getchar();

return 0;

}

fun(xxxx,alfa,licz,pierwszy)

char xxxx[],alfa;

int *licz,*pierwszy;

{

        int index,flag;

        *licz=0;

        index=0;

        flag=0;

        *pierwszy=0;

        while(xxxx[index]!='')

        {

        if(xxxx[index]==alfa)

        {

                *licz+=1;

                if(flag==0)

                {

                        *pierwszy=index+1;

                        flag=1;

                }

        }

                index+=1;

        }

        getchar();

}

This topic: Main > TWikiUsers > DorotaP > ProgramiK
Topic revision: 09 Jun 2004, DorotaP
 
This site is powered by FoswikiCopyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki? Send feedback