Skip to content
Snippets Groups Projects
Commit 037bee83 authored by Lucas B's avatar Lucas B
Browse files

Tp1 Pointeur

parent 7cad264f
No related branches found
No related tags found
No related merge requests found
Showing with 124 additions and 0 deletions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str[100] = "Hello World";
int diff = 'a' - 'A';
int espace = ' ';
for(int i = 0; i < strlen(str); i++){
if(str[i] == espace){
printf("%c", espace);
}
else if('A' < str[i] && str[i] < 'Z'){
printf("%c", str[i]);
}
else{
printf("%c", str[i] - diff);
}
}
return 0;
}
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int min(int *tab, int n){
int min = tab[0];
for(int i=1;i<n;i++){
if(tab[i]<min){
min = tab[i];
}
}
return min;
}
void sub(int *tab, int n, int s){
for(int i=0;i<n;i++){
tab[i] = tab[i] - s;
}
}
int main(){
int taille = 10;
int *str = (int*) malloc(taille*sizeof(int));
for(int i=0;i<10;i++){
scanf("%i",&str[i]);
}
int m = min(str,taille);
sub(str,taille,m);
for(int i=0;i<taille;i++){
printf("%d ",str[i]);
}
printf("\n");
return 0;
}
\ No newline at end of file
Code assembleur pas encore vu
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
int main() {
int taille = 11;
int *tab = (int *)malloc(taille * sizeof(int));
int *tabVide = (int *)malloc(taille * sizeof(int));
if (tab == NULL || tabVide == NULL) {
perror("Échec de l'allocation mémoire");
return EXIT_FAILURE;
}
// Initialisation du tableau `tab`
for (int i = 0; i < taille; i++) {
tab[i] = i;
}
// Remplissage de `tabVide`
for (int i = taille - 1; i >= taille / 2; i--) {
tabVide[2 * (taille - i - 1)] = tab[taille - i - 1];
if (taille - i - 1 != i){
tabVide[2 * (taille - i - 1) + 1] = tab[i];
}
}
// Affichage de `tabVide`
for (int i = 0; i < taille; i++) {
printf("%d ", tabVide[i]);
}
printf("\n");
// Libération de la mémoire
free(tab);
free(tabVide);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main() {
char* chaine = (char*) malloc(20);
char str = 'a';
int i = 0;
while (str != 10) {
scanf("%c", &str);
chaine[i%20] = str;
i++;
}
for (int j = 0; j < 20; j++) {
printf("%c", chaine[(i+j)%20]);
}
return 0;
}
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment