Skip to content
Snippets Groups Projects
Commit 389c2b90 authored by mathias.catala's avatar mathias.catala
Browse files

"first commit"

parent 97ae5251
No related branches found
No related tags found
No related merge requests found
Showing
with 404 additions and 0 deletions
File added
File added
File added
#include <stdio.h>
int main(){
int billet, billet50, billet20,billet10, billet100;
int piece5, piece2, piece1;
printf("Enter number less than 10000: ");
scanf("%d: ", &billet);
billet100 = billet / 100;
billet50= billet100/50;
billet20= billet50/20;
billet10=billet20/10;
piece5= billet10/5;
piece2=piece5/2;
piece1= piece2/1;
printf("billets: %i,%i,%i,%i,%i,%i,%i\n", billet100, billet50, billet20, billet10, piece5,piece2,piece1);
}
\ No newline at end of file
#include <stdio.h>
int main(){
int a;
int b;
int temp;
printf("Entrez la valeur a: ");
scanf("%d",&a);
printf("Entrez la valeur b: ");
scanf("%d",&b);
printf("valeurs avant a : %i\nvaleur b avant : %i",a,b);
temp = a;
a=b;
b=temp;
printf("\nvaleurs apres a :%d",a);
printf("\nvaleurs apres b :%d",b);
}
\ No newline at end of file
File added
File added
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#define TAILLE 8
char E[TAILLE][TAILLE];
typedef enum {empty,covered,queen}board_state;
// typedef struct{
// board_state board[SIZE_MAX][SIZE_MAX];
// int width, height;
// } board_t;
// fill board with queen covering given the position of the queen column, row
// return 0 in case of success, -1 otherwise (for example if queen is out of the board)
// int queen_covering(board_t *board, char line, int column){
// }
// print the given board in the terminal
//void print_board(board_t board){
int main(int argc, char **argv){
// int raws;
// int coloumn;
// printf("Entrez la ligne de la reine: ");
// scanf("%s",&line);
// printf("Entrez la colonne de la reine");
// scanf("%s",&coloumn);
// queen_covering()
// printf("Couverture de la reine:");
// print_board(board_t board);
// char *size = argv[1];
// char *height = argv[2];
int rows, cols, i, j, k;
/* Input rows and columns from user */
printf("Enter number of rows: ");
scanf("%d", &rows);
printf("Enter number of columns: ");
scanf("%d", &cols);
k = 1;
for(i=1; i<=rows; i++)
{
for(j=1; j<=cols; j++)
{
printf(". ");
// If k = 1 then k *= -1 => -1
// If k = -1 then k *= -1 => 1
k *= -1;
}
if(cols % 2 == 0)
{
k *= -1;
}
printf("\n");
printf("A");
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define SIZE_MAX 8
typedef enum {empty, covered, queen} board_state;
typedef struct {
board_state board[SIZE_MAX][SIZE_MAX];
int width, height;
} board_t;
int queen_covering(board_t *board, char line, int column){
for (int ligne = 0; ligne < SIZE_MAX; ++ligne){
for (int colonne =0; colonne < SIZE_MAX; ++colonne){
if (ligne == line-65 && colonne == column) {
board->board[ligne][colonne] = queen;
}else if (ligne == line-65 || colonne == column || abs(line-65-ligne)==abs(column-colonne)){
board->board[ligne][colonne] = covered;
}else {
board->board[ligne][colonne] = empty;
}
}
}
}
void print_board(board_t board) {
char index_h = 'H';
int index_w = 0;
for(int i = 0; i < SIZE_MAX +1; ++i) {
printf("\n");
for (int j =0; j < SIZE_MAX; ++j) {
if(j == 0) {
if (i == SIZE_MAX){
printf(" ");
}else {
printf("%c ", index_h);
}
}
if(i == SIZE_MAX) {
if (j != 0) {
printf("%d ", j);
}else {
printf(" ");
}
}else {
switch(board.board[i][j]) {
case covered:
printf("* ");
break;
case empty:
printf(". ");
break;
case queen:
printf("R ");
break;
}
}
}
--index_h;
}
printf("%d\n", SIZE_MAX);
}
int main() {
board_t board;
queen_covering(&board, 'C', 2);
print_board(board);
}
\ No newline at end of file
File added
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <time.h>
void ArrayFill( int tab[],int size){
for (unsigned i = 0; i < size; ++i)
{
tab[i] += i ;
printf("p[%u] = %d\n", i, tab[i]);
}
printf("\n");
}
void Display( int tab[],int size){
for (unsigned i = 0; i < size; ++i)
{
printf("p[%u] = %d\n", i, tab[i]);
}
printf("\n");
}
int *randomize2(int *tab, int size) {
for (int i = size-1 ; i >= 0; --i){
// generate Random number
int n_random = rand() % size;
// swap last element to
int temp = tab[i];
tab[i] = tab[n_random];
tab[n_random] = temp;
}
return tab;
}
int main(void)
{
srand(time(0));
int size=10;
//printf(" Entrez la valeur de size : ");
//scanf("%d",&size);
int *tab = malloc(size *sizeof(int));
// randomize(tab,size);
ArrayFill(tab,size);
randomize2(tab,size);
Display(tab,size);
free(tab);
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.exo1</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
File added
---
triple: 'arm64-apple-darwin'
binary-path: exo1
relocations:
- { offsetInCU: 0xDA, offset: 0xDA, size: 0x8, addend: 0x0, symName: _ArrayFill, symObjAddr: 0x0, symBinAddr: 0x100003C10, symSize: 0xB4 }
- { offsetInCU: 0x9F, offset: 0x9F, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x218, symBinAddr: 0x100003E28, symSize: 0x64 }
- { offsetInCU: 0xEC, offset: 0xEC, size: 0x8, addend: 0x0, symName: _randomize2, symObjAddr: 0x130, symBinAddr: 0x100003D40, symSize: 0xE8 }
- { offsetInCU: 0xF4, offset: 0xF4, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0x218, symBinAddr: 0x100003E28, symSize: 0x64 }
- { offsetInCU: 0x177, offset: 0x177, size: 0x8, addend: 0x0, symName: _Display, symObjAddr: 0xB4, symBinAddr: 0x100003CC4, symSize: 0x7C }
- { offsetInCU: 0x17F, offset: 0x17F, size: 0x8, addend: 0x0, symName: _randomize2, symObjAddr: 0x130, symBinAddr: 0x100003D40, symSize: 0xE8 }
- { offsetInCU: 0x1D7, offset: 0x1D7, size: 0x8, addend: 0x0, symName: _ArrayFill, symObjAddr: 0x0, symBinAddr: 0x100003C10, symSize: 0xB4 }
- { offsetInCU: 0x1DF, offset: 0x1DF, size: 0x8, addend: 0x0, symName: _Display, symObjAddr: 0xB4, symBinAddr: 0x100003CC4, symSize: 0x7C }
...
File added
#include <stdio.h>
void foo(int a) {
a += 3;
}
void bar(int *a) {
*a += 3;
}
void baz(int *a) {
a += 3;
}
int main() {
int a = 5;
printf("%i\n", a);
foo(a);
printf("%i\n", a);
bar(&a);
printf("%i\n", a);
baz(&a);
printf("%i\n", a);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.exo2</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
File added
---
triple: 'arm64-apple-darwin'
binary-path: exo2
relocations:
- { offsetInCU: 0x26, offset: 0x26, size: 0x8, addend: 0x0, symName: _foo, symObjAddr: 0x0, symBinAddr: 0x1000037A0, symSize: 0x1C }
- { offsetInCU: 0x3B, offset: 0x3B, size: 0x8, addend: 0x0, symName: _.str, symObjAddr: 0x5A0, symBinAddr: 0x100003DC0, symSize: 0x0 }
- { offsetInCU: 0x5E, offset: 0x5E, size: 0x8, addend: 0x0, symName: _foo, symObjAddr: 0x0, symBinAddr: 0x1000037A0, symSize: 0x1C }
- { offsetInCU: 0x82, offset: 0x82, size: 0x8, addend: 0x0, symName: _bar, symObjAddr: 0x1C, symBinAddr: 0x1000037BC, symSize: 0x90 }
- { offsetInCU: 0xA6, offset: 0xA6, size: 0x8, addend: 0x0, symName: _baz, symObjAddr: 0xAC, symBinAddr: 0x10000384C, symSize: 0x1C }
- { offsetInCU: 0xCA, offset: 0xCA, size: 0x8, addend: 0x0, symName: _main, symObjAddr: 0xC8, symBinAddr: 0x100003868, symSize: 0x440 }
...
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void shuffle(int *array, int n) {
int i, j, tmp;
for (i = n - 1; i > 0; i--) {
j = rand()% (i+1);
tmp = array[j];
array[j] = array[i];
array[i] = tmp;
}
}
int main(void)
{
int i = 0;
int numbers[10];
for (i = 0; i < 10; i++)
numbers[i]= i;
shuffle(numbers, 10);
printf("\nArray after shuffling is: \n");
for ( i = 0; i < 10; i++)
printf("p[%u] = %d\n", i, numbers[i]);
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment