Filip

Kolorwanie:
Status:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int porownanie(char* napis1,char* napis2)
{
    return strcmp(napis1,napis2);
}
 
int main(){
 
 
    char* napis = new char[255];
    strcpy(napis,"Ala ma kota");
    char* napis2 = new char[255];
    strcpy(napis2,"Ala ma kota");
    cout<<(porownanie(napis,napis2)>0? "pierwszy jest wiekszy":porownanie(napis,napis2)==0? "sa rowne":"drugi jest wiekszy");
    delete napis;
    delete napis2;
    return 0;
}


#include <iostream>
#include <string.h>
#include <string>

using namespace std; 

// wlasna funckja
string foo(string str, int limit)
{
    string strNew;
    for (int i = 0; i < limit; ++i)
        strNew += str[i];
    return strNew;
}

//std funckja
char* foo2(char* str_ch, int limit)
{
    char* strNew_ch = new char[limit];
    strncpy(strNew_ch, str_ch, limit);
    return strNew_ch;
}
 
int main()
{
    string str = "Ala ma kotka";
    char *str_ch = new char[255];
    strcpy(str_ch, "Ala ma kota");
    int limit;
    cin >> limit;
    string res = foo(str, limit);
    char* res_ch = foo2(str_ch, limit);
    cout << res_ch;
    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int foo(char * napis, char * napis_1)
{
    int dl = strlen(napis_1);
    int  ile=0;
    for( char * ptr = strstr(napis, napis_1); ptr != 0; ptr = strstr(ptr+dl, napis_1),ile++);
    return ile;
}

int main()
{
    char napis[]="maalakotama";
    char napis_1[]="ma";
    cout << foo(napis,napis_1);

    return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int foo(char * napis, char * napis_1)
{
    int  ile=0;
    for( char * ptr = strpbrk(napis, napis_1); ptr != 0; ptr = strpbrk(ptr+1, napis_1),ile++);
    return ile;
}

int main()
{
    char napis[]="maalakotama";
    char napis_1[]="aAeEyYuUiIoO";
    cout << foo(napis,napis_1);

    return 0;
}

include <stdio.h>
#include <string.h>
#include <iostream>

void foo(char str[][50], char * temp)
{
    for (int i = 0; i < 5; ++i) {
      for (int j = i + 1; j < 5; ++j) {
         if (strcmp(str[i], str[j]) > 0) {
            strcpy(temp, str[i]);
            strcpy(str[i], str[j]);
            strcpy(str[j], temp);
         }
      }
   }
   for (int i = 0; i < 5; ++i)
     std::cout << str[i] << std::endl;
}

int main() {
   char str[5][50], temp[50];

   for (int i = 0; i < 5; ++i)
   std::cin >> str[i];
    foo(str, temp);

   return 0;
}

Copyrights 2014-2021 © Wklejaj.pl Wszelkie prawa zastrzeżone.