江南信息学2023年第一周练习20230223 题解

比赛链接

1001 : 鸡尾酒疗法

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     cin>>n;
 7     double a,b;
 8     cin>>a>>b;
 9     double c = b/a; 
10     n--;
11     while(n--)
12     {
13         double x,y;
14         cin>>x>>y;
15         double z=y/x;
16         if(z-c>0.05)cout<<"better"<<endl;
17         else if(c-z>0.05)cout<<"worse"<<endl;
18         else cout<<"same"<<endl;        
19     }
20 
21     return 0;
22 }

 

1002 : 判断是否存在重复的数

1 #include<bits/stdc++.h>
2 using namespace std;
3 int main(){
4     int x,y,z;
5     cin>>x>>y>>z;
6     if(x==y||x==z||y==z)cout<<"YES"<<endl;
7     else cout<<"NO"<<endl;
8     return 0;
9 }

 

1003 : 计算表达式的值

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int x,y,s,d;
 6     cin>>x>>y;
 7     s=3*x;
 8     d=2*y;
 9     cout<<s+d;
10     return 0;
11 }

 

1004 : 日期输出

1 #include<bits/stdc++.h>
2 using namespace std;
3 int main()
4 {
5     int n,m;
6     cin>>n>>m;
7     printf("%02d-%02d",n,m);
8     return 0;
9 }

 

1005 : 与指定数字相同的数的个数

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {    
 5     int n,m,s,sum=0;
 6     cin>>n>>m;
 7     for(int i=1;i<=n;i++){
 8         cin>>s;
 9         if(m==s)
10         sum++;
11         }
12     cout<<sum;
13     return 0;
14 }

 

1006 : 列表索引问题简单版2

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main(){
 4     char a[25];
 5     int n;
 6     cin>>a;
 7     cin>>n;
 8     cout<<a[n-1];
 9     return 0;
10 }

 

1007 : 列表索引问题简单版3

1 #include<bits/stdc++.h>
2 using namespace std;
3 int main(){
4     char a[25];
5     cin>>a;
6     cout<<a[strlen(a)-5];
7     return 0;
8 }

 

posted @ 2023-02-28 15:43  CRt0729  阅读(35)  评论(0)    收藏  举报