First, insert the assembly
1#include <stdio.h>2 3 voidMain () {4 intnum=Ten;5num=num+5;6 //Insert assembly Language7 _asm{8MOV eax,num;//EAX is a memory that moves the value of num to EAX9add eax,5 //eax value +5TenMOV num,eax//EAX value assigned to NUM One } Aprintf"%d", num); - GetChar (); -}
Second, the calculation of modulus, subversion number
1#include <stdio.h>2#include <stdlib.h>3 4 voidmain1 () {5 //int num=5%9.0;//Error,modulo operations can only be integers6 //int num= ' A '%3;//65%3=27printf"%d",3%5);//3=0*5+38printf"\n%d",5%3);//5=1*3+29printf"\n%d",3%-5);//3=1*-5+3Tenprintf"\n%d",-3%-5);//-3=0*-5-3 Oneprintf"\n%d",-3%5);//-3=0*5-3 Aprintf"\n%d",5%-3);//5=-1*-3+2 - GetChar (); - } the //Interview questions: Don't use modulo arithmetic - /* - 120%19->6=120-120/19*19 - 100%40->20=100-100/40*40 + X%y=x-x/y*y - */ + voidmain2 () { A intx, y; atscanf"%d%d",&x,&y); -printf"x=%d,y=%d", x, y); - //printf ("\n%d", x%y); -printf"\n%d", x-x/y*y); - -System"Pause"); in } - //Subversion number 123->321 456->654 to voidMain () { + intNum,ge,shi,bai; -scanf"%d",&num); the *ge=num%Ten; $shi=num/Ten%Ten;Panax Notoginsengbai=num/ -; - theprintf"%d", ge* -+shi*Ten+Bai); +System"Pause"); A}
Exercise: four-digit subversion, no use of modulo arithmetic
1#include <stdio.h>2#include <stdlib.h>3 voidMain () {4 intNum,ge,shi,bai,qian;5scanf"%d",&num);6 7ge=num-num/Ten*Ten;8shi=num/Ten-num/ -*Ten;9bai=num/ --num/ +*Ten;Tenqian=num/ +; One Aprintf"%d", ge* ++shi* -+bai*Ten+Qian); -System"Pause"); -}
Iii. self-increasing self-reduction
1#include <stdio.h>2#include <stdlib.h>3 4 voidmain2 () {5 //++--above multiplication, multiplication higher than +-6 intnum=3;7printf"%d",-num++);//-38printf"\n%d", num);//49System"Pause");Ten } One voidMain () { A intA=3; - intb=4; - intnum=Ten; theprintf"%d", a+++b);//(a++) +b -printf"\n%d", a);//4 - - //printf ("\n%d", (10*num) + +);//error, "+ +" requires an lvalue (expression cannot be used ++--) +printf"\n%d",Ten*num++);// - -System"Pause"); +}
Programming Road (8), assembly, modulus, self-increment/decrement