首页 > 其他分享 >2023.4.14

2023.4.14

时间:2023-04-14 23:44:07浏览次数:30  
标签:arr 14 int namespace 2023.4 x0 include cout

 1 //编程一百题
 2 //1.4抓交通肇事犯
 3 #include <iostream>
 4 using namespace std;
 5 int num = 0;
 6 int main()
 7 {
 8     for(int i=1;i<=9;i++)
 9     {
10         for(int j=0;j<=9;j++)
11         {
12             if(i != j)
13             {
14                 num = 1000*i+100*i+10*j+j;
15             }
16             for(int k=31;k<100;k++)
17             {
18                 if(k*k == num)
19                 {
20                     cout<<num;
21                 }
22             }
23         }
24     }
25 
26     return 0;
27 }
 1 //编程一百题
 2 //1.5兔子产子问题
 3 #include <iostream>
 4 using namespace std;
 5 int main()
 6 {
 7     int arr[30];
 8     arr[0] = arr[1] = 1;
 9     cout<<"第"<<1<<"个月的兔子对数为:"<<arr[0]<<endl;
10     cout<<"第"<<2<<"个月的兔子对数为:"<<arr[1]<<endl;
11     for(int i=2;i<30;i++)
12     {
13         arr[i] = arr[i-1] + arr[i - 2];
14         cout<<"第"<<i+1<<"个月的兔子对数为:"<<arr[i]<<endl;
15     }
16 
17     return 0;
18 }
 1 //编程一百题
 2 //1.6牛顿迭代法求方程根
 3 #include <iostream>
 4 using namespace std;
 5 #include <math.h>
 6 int main()
 7 {
 8     double a,b,c,d,x0,x = 1.5,x1=0;
 9     cout<<"请输入系数:"<<endl;
10     cin>>a>>b>>c>>d;
11 Flag:
12     x0 = x;
13     x1 = x0 - (a*x0*x0*x0+b*x0*x0+c*x0+d)/(3*a*x0*x0+2*b*x0+c);
14     x = x0 - x1;
15     if(fabs(x - x0)>0.00001)
16     {
17         goto Flag;
18     }
19     else
20     {
21         cout<<x;
22     }
23     return 0;
24 }

 

标签:arr,14,int,namespace,2023.4,x0,include,cout
From: https://www.cnblogs.com/muzhaodi/p/17320267.html

相关文章