re
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <stdlib.h>
|
||||
//#include <stdio.h>
|
||||
int *count(int n){
|
||||
if (n < 1) return NULL;
|
||||
int *p = malloc(n);
|
||||
if(p == NULL) return NULL;
|
||||
|
||||
while (n != 0){
|
||||
|
||||
*(p + n-1) = n;
|
||||
n --;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
/*
|
||||
int main(){
|
||||
int *rslt = count(5);
|
||||
int index = 0;
|
||||
|
||||
while(*(rslt + index)){
|
||||
|
||||
printf("%i", *(rslt + index));
|
||||
index ++;
|
||||
}
|
||||
free(rslt);
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *my_weirddup(char *src){
|
||||
|
||||
if(src == NULL) return NULL;
|
||||
|
||||
int index = 0;
|
||||
while(*(src)){
|
||||
index ++;
|
||||
src ++;
|
||||
}
|
||||
|
||||
char *str = malloc(index + 1);
|
||||
if(str == NULL) return NULL;
|
||||
|
||||
//src = 0;
|
||||
|
||||
char lettre = ' ';
|
||||
index = 0;
|
||||
|
||||
while (*src){
|
||||
lettre = *src;
|
||||
|
||||
//maj
|
||||
if (lettre > 64 && lettre < 91){
|
||||
if (lettre == 'Z') lettre = 'A';
|
||||
else lettre += 1;
|
||||
}
|
||||
|
||||
//min
|
||||
else if (lettre > 97 && lettre < 124 ){
|
||||
|
||||
if (lettre == 'z')lettre = 'a';
|
||||
else lettre += 1;
|
||||
}
|
||||
|
||||
*str = lettre;
|
||||
src ++;
|
||||
str ++;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
printf("%s",my_weirddup("abb"));
|
||||
|
||||
}
|
||||
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user