一、插入汇编

 #include<stdio.h>

 void main(){
int num=;
num=num+;
//插入汇编语言
_asm{
mov eax,num;//eax是一个存储器,将num的值移动到eax
add eax, //eax值+5
mov num,eax //eax值赋给num
}
printf("%d",num);
getchar();
}

二、求模运算,颠覆数

 #include<stdio.h>
#include<stdlib.h> void main1(){
//int num=5%9.0;//报错,求模运算只能是整数
//int num='A'%3;//65%3=2
printf("%d",%);//3=0*5+3
printf("\n%d",%);//5=1*3+2
printf("\n%d",%-);//3=1*-5+3
printf("\n%d",-%-);//-3=0*-5-3
printf("\n%d",-%);//-3=0*5-3
printf("\n%d",%-);//5=-1*-3+2
getchar();
}
//面试题:不准用求模运算
/*
120%19->6=120-120/19*19
100%40->20=100-100/40*40
x%y=x-x/y*y
*/
void main2(){
int x,y;
scanf("%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");
}
//颠覆数 123->321 456->654
void main(){
int num,ge,shi,bai;
scanf("%d",&num); ge=num%;
shi=num/%;
bai=num/; printf("%d",ge*+shi*+bai);
system("pause");
}

练习:四位数颠覆,不允许使用求模运算

 #include<stdio.h>
#include<stdlib.h>
void main(){
int num,ge,shi,bai,qian;
scanf("%d",&num); ge=num-num/*;
shi=num/-num/*;
bai=num/-num/*;
qian=num/; printf("%d",ge*+shi*+bai*+qian);
system("pause");
}

三、自增自减

 #include<stdio.h>
#include<stdlib.h> void main2(){
//++--高于乘除,乘除高于+-
int num=;
printf("%d",-num++);//-3
printf("\n%d",num);//
system("pause");
}
void main(){
int a=;
int b=;
int num=;
printf("%d",a+++b);//->(a++)+b
printf("\n%d",a);//4 //printf("\n%d",(10*num)++);//报错,“++”需要左值(表达式不能用++--)
printf("\n%d",*num++);//
system("pause");
}
05-08 08:32