回复 149楼 beyondyf
不是和你提过挑战杯吗,我报的智慧养老院,是基于嵌入式开发方面的,配合下位机脉搏传感器,温度传感器什么,最后做成一个远程控制的web网络监控系统。对了,杨大哥你搞过嵌入式吗?
编程之路定要走完……
#include <stdio.h> void find(double x,int max,int* pd,int* pn) { int dSmall=0 ,nSmall=1, dBig = 1 ,nBig =0; while(1) { int dCurr=dSmall+dBig; int nCurr=nSmall+nBig; if((double)dCurr/(double)nCurr > x) dBig = dCurr, nBig=nCurr, *pd = dSmall, *pn = nSmall; else dSmall=dCurr,nSmall=nCurr, *pd = dBig, *pn = nBig; if(dCurr>max || nCurr>max) return; } } int main(int argc, char *argv[]) { double a; int b; while(scanf("%lf%d",&a,&b)) { int numerator,denominator; find(a,b,&denominator,&numerator); printf("%d %d\n",denominator,numerator); } return 0; }
#include <stdio.h> void find(double x,unsigned int max,unsigned int* pd,unsigned int* pn) { unsigned int dSmall=0 ,nSmall=1, dBig = 1 ,nBig = 0; while(1) { unsigned int dCurr=dSmall+dBig; unsigned int nCurr=nSmall+nBig; if(dCurr>max || nCurr>max) break; if((double)dCurr/(double)nCurr > x) dBig = dCurr, nBig=nCurr; else dSmall=dCurr,nSmall=nCurr; } if((double)dBig/(double)nBig - x > x-(double)dSmall/(double)nSmall ) *pd = dSmall,*pn = nSmall; else *pd = dBig,*pn = nBig; return; } int main(int argc, char *argv[]) { double a; unsigned int b; while(scanf("%lf%d",&a,&b)>0) { unsigned int numerator,denominator; find(a,b,&denominator,&numerator); printf("%d %d\n",denominator,numerator); } return 0; }
double x=1,y=0; printf("%e\n",x/y);
#include <stdio.h> #include <math.h> #define MAX 10000 int primeTable[MAX]; int primeCount=1; int isPrime(int num) { int i; for(i=0;i<primeCount&&primeTable[i]<sqrt(num)+1;i++) if(num%primeTable[i]==0) return 0; return 1; } void mkPrime(int end) { int i; for(i=primeTable[primeCount-1]|0x01;i<end;i+=2) if(isPrime(i)) primeTable[primeCount++]=i; } int main(int argc, char *argv[]) { long n; primeTable[0]=2; mkPrime(50000); while(scanf("%ld",&n)&&n) { int i=0,bFirst=0; while(n!=1&&i<primeCount) { while(n%primeTable[i]==0) { if(bFirst++) printf("*"); printf("%d",primeTable[i]); n/=primeTable[i]; } i++; } if(i==primeCount) { if(bFirst++) printf("*"); printf("%d",n); } printf("\n"); } return 0; }