1. 程式人生 > >提取四位數的千位,百位,十位,個位

提取四位數的千位,百位,十位,個位

// bit.cpp : Defines the entry point for the console application.
//

/*
x-->千位
y-->百位
z-->十位
w-->個位
*/

#include "stdafx.h"
#include "stdio.h"

int main(int argc, char* argv[])
{
 int i=5687;
 int x,y,z,w;
 x=i/1000;
 y=(i-x*1000)/100;
 z=(i-x*1000-y*100)/10;
 w=i-x*1000-y*100-z*10;
 printf("x is : %d/n",x);
 printf("y is : %d/n",y);
 printf("z is : %d/n",z);
 printf("w is : %d/n",w);
 return 0;
}