标签:seq ble 控制 can 竞赛 比较 输出 include code
enmmmmmm】 大部分好像除了最后一个思考题都很简单
代码如下
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> int main(){ /* for(int i =100 ; i <= 999 ; i++) { int a = i/100;int c = i%10;int b = (i-a*100)/10;//水仙花数 if( i == pow(a,3)+pow(b,3)+pow(c,3)) WA //if( i == a*a*a+b*b*b+c*c*c) //AC printf("%d= %d^3 + %d^3 + %d^3\n",i,a,b,c); }*/ /*int a,b,c,kase=1;//2-2hanxin韩信 while(scanf("%d%d%d",&a,&b,&c) == 3 )//3 5 7 { int flag =0; printf("Case %d: ",kase++); a = a*70+b*21+c*15; while(a >= 105){ a -= 105; } if(a <=10 || a>=100 )printf("No answer\n"); else printf("%d\n",a ); //for(int i = 10;i <= 100 ; i++) // if(i%3==a && i%5==b && i%7==c) // {printf("%d\n",i);flag=1;} //if(!flag) printf("No answer\n" ); }*/ /* int n;scanf("%d",&n);//2-3triangle倒三角形 for(int i = n;i >= 1 ;i--) { for(int j = n-i ;j > 0;j--)printf(" "); for(int j = i*2-1;j > 0;j--)printf("#"); for(int j = n-i ;j > 0;j--)printf(" "); printf("\n"); }*/ /*int n,m;while( scanf("%d%d",&n,&m)==2 ) {//2-4子序列的和 subsequence if(n == 0 && n == m)break; double ans = 0.0; for( int i = n ; i <= m;i++) { ans += (1.0/i)*(1.0/i); //直接1.0/(i*i)就炸 //sum += 1 / (((double)n + i) * ((double)n + i)); //在n较大时,((double)n + i) * ((double)n + i)会溢出, //所以应该改成 1 / ((double)n + i) / ((double)n + i) //printf("i=%d ans=%.5lf\n", i,ans); }printf("%.5lf\n", ans);//printf("%u %u\n", -1,-2); }*/ /* int a,b,c,n,n1; while(scanf("%d%d%d",&a,&b,&c)==3 && (a||b||c)) { for(int count=0; ;count++) { if(count) { if(count<=c) printf("%d",n); else { if(n1=a/b >= 5) n++; printf("%d",n); break; } n=a/b; a=(a-n*b)*10; if(count == 1) std::cout<<"."; } } } int a,b,c,kase=0,i; while(scanf("%d%d%d",&a,&b,&c)&&a&&b&&c){ printf("Case %d: %d.",++kase,a/b); a%=b; for( i = 1; i < c; i++){ printf("%d",a*10/b); a=a*10%b; } if( a*10%b*10/b >= 5) a*10/b++; printf("%d\n",a*10/b); }*/ /* int a,b,c;//2-5分数化小数 decimal while(scanf("%d%d%d",&a,&b,&c)==3 ){ if( a== b && b==c && a==0)break; int aa[505],bb[505]; aa[0] = a/b; aa[1] = a*10/b; for(int i=2; i <= c+1;i++) { bb[i] = a*10%b; aa[i] = bb[i]*10/b; }//printf("%d.",aa[0]); if(aa[c+1] >= 5 )aa[c] += 1; for(int i=c; i >= 1 ;i--) if(aa[i] == 10) aa[i]-=10,aa[i-1]+1; printf("%d.",aa[0] ); for(int i=1; i < c; i++) printf("%d",aa[i] ); printf("%d\n",aa[c]); } int a,b,c;while(scanf("%d%d%d",&a,&b,&c) == 3 && a){ //if(a <= 1e+6 && b <= 1e+6 && c <= 200 && a != 0 && b != 0 && c != 0){ printf("%.*lf\n",c,(double)a / (double)b); //} }*/ /*for(int i=123; i <= 333; i++) {//排列 bool aa[10]={false}; int flag =0 ; aa[i/100] = aa[i/10%10] = aa[i%10]=true; int j = i*2; int k = i*3; aa[j/100] = aa[j/10%10] = aa[j%10]=true; aa[k/100] = aa[k/10%10] = aa[k%10]=true; for(int d= 1; d <= 9; d++) { if( aa[d] == false ) {flag=1;break;} } if( !flag ) printf("%d:%d:%d\n", i,j,k); } int n;scanf("%d",&n); for(int i = 1; i <= n; i++)//for(int i = 2; i <= n; i+=2) printf("%d\n", 2*i);*/ double i = 0; for( i = 0; i != 10; i += 0.1) printf("%f", i); return 0; }
至于最后一个思考题 浮点数陷阱
把 10 改成10.0 10.000000 啥的都没用 脑阔疼 搜了下发现了这个博客 http://blog.sina.com.cn/s/blog_6da76f9b0100yr8d.html
标签:seq ble 控制 can 竞赛 比较 输出 include code
原文地址:https://www.cnblogs.com/163467wyj/p/9769803.html