Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

a=1. b=2. do 10 i=3,20 c=a+b v=c/b write(1,20)i,v a=b 10 b=c 20 format(1x,i3,f13.8) end…

  1. User

    a=1. b=2. do 10 i=3,20 c=a+b v=c/b write(1,20)i,v a=b 10 b=c 20 format(1x,i3,f13.8) end переведи код на c++

  2. Assistant
    #include <iostream>
    #include <iomanip>
    
    int main() {
        double a = 1.0;
        double b = 2.0;
    
        for (int i = 3; i <= 20; i++) {
            double c = a + b;
            double v = c / b;
            std::cout << std::setw(3) << i << std::setw(13) << std::fixed << std::setprecision(8) << v << std::endl;
            a = b;
            b = c;
        }
    
        return 0;
    }
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.