#include <stdio.h>
void change(int *,int*);
int main ()
{
int a=2,b=5;
printf("Avant : a=%d,b=%d\n",a,b);
change(&a,&b);
printf("Apres : a=%d,b=%d\n",a,b);
return 0;
}
void change(int *a,int *b){
*a += *b;
*b = *a-*b;
*a = *a-*b;
}
lami20j@debian:~/trash$ gcc permuter_var.c lami20j@debian:~/trash$ ./a.out Avant : a=2,b=5 Apres : a=5,b=2
#include <stdio.h>
#define PERMUTER(x,y) x ^= y, y ^= x, x ^= y
int main ()
{
int a=2,b=5;
printf("Avant : a=%d,b=%d\n",a,b);
PERMUTER(a,b);
printf("Apres : a=%d,b=%d\n",a,b);
return 0;
}
vlmath@debian:~$ gcc permuter_var.c vlmath@debian:~$ ./a.out Avant : a=2,b=5 Apres : a=5,b=2
Autres Astuces dans la catégorie Langage C
| 15/06 10h21 | Windows ne peut pas charger le profil local | Windows |
| 27/05 09h47 | Les templates | Langage C++ |
| 26/04 02h08 | Température Processeur | Processeur |
| 03/09 12h55 | [Sécurité] Utilisation d'un firewall | Sécurité |
| 29/10 15h43 | Permuter deux nombre sans utiliser temp | 2 |
| 20/01 19h20 | Utiliser 2 souris en même temps | 6 |
| 28/03 16h04 | Cmt utiliser 2 messengers en mm temps | 0 |
| 28/03 13h21 | [MSN] comment utiliser 2 émails en meme temps | 29 |
| 25/08 16h00 | UC utilisé - Temps du noyau 100% | 5 |
![]() | Tight VNC - VNC (Virtual Network Computing) est une application client/serveur permettant d'accéder graphiquement à une machine... | Catégorie: Connexion à distance Licence: Open Source |
![]() | Notepad++ - Notepad++ est un editeur de code source qui supporte plusieurs langages. Il s'agit d'un logiciel libre performant et... | Catégorie: Développement Licence: Open Source |
![]() | SuperDocker - SuperDocker est un programme de personnalisation des différents éléments de votre MacOSX Leopard. En utilisant cette... | Catégorie: Personnalisation Licence: Freeware/gratuit |
![]() | Visual Basic Express 2005 - Le langage de programmation Visual Basic est historiquement dans les gènes de la société Microsoft. Avec plus de 30.000... | Catégorie: Visual Basic Licence: Freeware/gratuit |
![]() | Alcatel TEMPORIS 26N Black | Catégorie: Téléphone fixe | |
![]() | CnMemory Vario 2 Go | Catégorie: Carte Mémoire / Clé USB | |
![]() | Leica Digilux 3 / | Catégorie: Appareil photo numérique | |
![]() | Alcatel Temporis 250 Pro | Catégorie: Téléphone fixe | 26.00 € Alapage |