小编use*_*730的帖子

Sierpinski三角形的周长

我正在为自己的实践做这个问题.我设法通过所有的测试用例,所以我无法弄清楚什么是错的.我的代码是:

#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
int main(){
   int num = 1;

   while(true){
    string line,stringRes;
    getline(cin,line);
    if(cin.eof()){break;}
    long double shrinks = atof(line.c_str());

    long double triangels = pow(3,shrinks);
    long double length = 3/pow(2,shrinks);
    long double res = floor(triangels* length * 3);
    int i = 0;
    while(res >= 10){
        i++;
        res =  res/10;
    };
    if(shrinks == 1){
        printf("Case %d: %d\n",num ,1);
    }else{
        printf("Case %d: %d\n",num ,i+1);
    }
    num++;
}
return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c++ math c++11 c++14

1
推荐指数
1
解决办法
612
查看次数

标签 统计

c++ ×1

c++11 ×1

c++14 ×1

math ×1