reorder

Un outil pour réarranger les lignes de stdin - retour accueil

git clone git://bebou.netlib.re/reorder
Log | Files | Refs | README |

commit 0bca3679c889ac58554476af97a09845927783aa
parent 48ad2b2c7af6c6be0e9b2f732fea5544c60330b7
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Fri, 17 Jan 2025 12:38:49 +0100

Factorisation retrait d'une carte d'une pile

Mon dieu ça fait presque sens

Diffstat:
Mreorder.c | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/reorder.c b/reorder.c @@ -21,6 +21,13 @@ void addcardtopile(char* cardname, struct pile* p) { p->cardCount++; } +void removecardofpile(int cardposition, struct pile* p) { + p->cardCount--; + for(int i=cardposition;i<p->cardCount;i++) { + p->cards[i]=p->cards[i+1]; + } +} + struct pile file2pile(FILE *fp) { struct pile pi; struct pile *p=&pi; @@ -131,10 +138,7 @@ int main(int argc, char **argv) { if (curmenu=="played") { if (selection) { addcardtopile(played.cards[curline],h); - played.cardCount--; - for(int w=curline;w<played.cardCount;w++) { - played.cards[w]=played.cards[w+1]; - } + removecardofpile(curline,p); } curmenu="hand"; curline=hand.cardCount-1; @@ -145,10 +149,7 @@ int main(int argc, char **argv) { if (curmenu=="hand") { if (selection) { addcardtopile(hand.cards[curline],p); - hand.cardCount--; - for(int w=curline;w<hand.cardCount;w++) { - hand.cards[w]=hand.cards[w+1]; - } + removecardofpile(curline,h); } curmenu="played"; curline=played.cardCount-1;