标签:
#include<stdio.h> #include<stdlib.h> #include<time.h> int main()//猜数游戏 { int count=0,flag,mynumber,yournumber; srand(time(0)); mynumber=rand()%100+1; flag=0; while(count<5){ printf("请输入所猜数字:"); scanf("%d",&yournumber); count++; if(yournumber==mynumber){ printf("Lucky You!\n"); flag=1; break; } else if(yournumber>mynumber) printf("Too big\n"); else printf("Too small\n"); } if(flag==0) printf("Game Over!\n"); return 0; }
#include<stdio.h>//求两个数的最大公约数和最小公倍数 int main() { int a; int b; int x; int y; int g=1; printf("请输入两个数"); scanf("%d %d",&a,&b); x=a; for(x=2;x<=a;x+) { if(a%x==0 && b%x==0) g=x; } printf("最大公约数:%d",g); g=a*b; for(x=a*b-1;x>=a;x--) printf("最小公倍数:%d",g); }
标签:
原文地址:http://www.cnblogs.com/lmj863337969/p/5944042.html