Browse Source

solutions in cpp for contest 1200

zj 5 years ago
parent
commit
1c5c89118a
9 changed files with 125 additions and 0 deletions
  1. 11 0
      C.cpp
  2. 20 0
      D.cpp
  3. 15 0
      E.cpp
  4. 9 0
      E2.cpp
  5. 14 0
      F.cpp
  6. 12 0
      F2.cpp
  7. 14 0
      G.cpp
  8. 17 0
      H.cpp
  9. 13 0
      I.cpp

+ 11 - 0
C.cpp

@@ -0,0 +1,11 @@
+#include<bits/stdc++.h>
+using namespace std;
+int main(){
+    int a;
+    cin>>a;
+    if(a%4==0&&a%100!=0||a%400==0)
+        cout<<"yes";
+    else
+        cout<<"no";
+    return 0;
+}

+ 20 - 0
D.cpp

@@ -0,0 +1,20 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int n;
+    cin >> n;
+    bool flag = true;
+    for (int i = 2; i <= n - 1; i++)
+        if (n % i == 0) {
+            flag = false;
+            break;
+        }
+    if (flag) {
+        cout << "prime" << endl;
+    } else {
+        cout << "not prime" << endl;
+    }
+    return 0;
+}

+ 15 - 0
E.cpp

@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int Max = INT_MIN;
+    for (int i = 0; i < 10; i++) {
+        int t;
+        cin >> t;
+        Max = max(t, Max);
+    }
+    cout << Max << endl;
+
+    return 0;
+}

+ 9 - 0
E2.cpp

@@ -0,0 +1,9 @@
+#include<bits/stdc++.h>
+using namespace std;
+int main(){
+    int a[10];
+    for(int i=0;i<10;i++)cin>>a[i];
+    cout<<*max_element(a,a+10)<<endl;
+
+    return 0;
+}

+ 14 - 0
F.cpp

@@ -0,0 +1,14 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int a, b, c;
+    cin >> a >> b >> c;
+    if (a > b)swap(a, b);
+    if (b > c)swap(b, c);
+    if (a > b)swap(a, b);
+    cout << a << " " << b << " " << c << endl;
+
+    return 0;
+}

+ 12 - 0
F2.cpp

@@ -0,0 +1,12 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int a[3];
+    cin >> a[0] >> a[1] >> a[2];
+    sort(a, a + 3);
+    cout << a[0] << " " << a[1] << " " << a[2] << endl;
+
+    return 0;
+}

+ 14 - 0
G.cpp

@@ -0,0 +1,14 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    int n;
+    cin >> n;
+    if (n % 15 == 0)
+        cout << "can" << endl;
+    else
+        cout << "cannot" << endl;
+
+    return 0;
+}

+ 17 - 0
H.cpp

@@ -0,0 +1,17 @@
+#include<bits/stdc++.h>
+using namespace std;
+int main(){
+    double a,b,c;
+    cin>>a>>b>>c;
+    double dt=b*b-4*a*c;
+    if(dt<0){
+        cout<<"no answer";
+    }else{
+        double x1=(-b-sqrt(dt))/(2*a);
+        double x2=(-b+sqrt(dt))/(2*a);
+        cout<<fixed<<setprecision(4)<<x1<<" "<<x2<<endl;
+    }
+
+
+    return 0;
+}

+ 13 - 0
I.cpp

@@ -0,0 +1,13 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int main() {
+    double F;
+    cin >> F;
+    cout << "F=" << fixed << F << endl;
+    double C = (F - 32) * 5 / 9;
+    cout << "C=" << fixed << C << endl;
+
+    return 0;
+}