Browse Source

refine codes

zj 5 years ago
parent
commit
74ae34753a
11 changed files with 91 additions and 92 deletions
  1. 5 5
      A.cpp
  2. 7 7
      B.cpp
  3. 9 9
      C.cpp
  4. 14 14
      D.cpp
  5. 9 9
      E.cpp
  6. 6 6
      E2.cpp
  7. 8 8
      F.cpp
  8. 6 6
      F2.cpp
  9. 8 8
      G.cpp
  10. 13 14
      H.cpp
  11. 6 6
      I.cpp

+ 5 - 5
A.cpp

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

+ 7 - 7
B.cpp

@@ -1,13 +1,13 @@
-#include<bits/stdc++.h>
+#include <bits/stdc++.h>
 
 using namespace std;
 
 int main() {
-    int id, score;
-    while (cin >> id >> score) {
-        if (score >= 80) {
-            cout << id << " " << score << endl;
-        }
+  int id, score;
+  while (cin >> id >> score) {
+    if (score >= 80) {
+      cout << id << " " << score << endl;
     }
-    return 0;
+  }
+  return 0;
 }

+ 9 - 9
C.cpp

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

+ 14 - 14
D.cpp

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

+ 9 - 9
E.cpp

@@ -1,15 +1,15 @@
-#include<bits/stdc++.h>
+#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;
+  int Max = INT_MIN;
+  for (int i = 0; i < 10; i++) {
+    int t;
+    cin >> t;
+    Max = max(t, Max);
+  }
+  cout << Max << endl;
 
-    return 0;
+  return 0;
 }

+ 6 - 6
E2.cpp

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

+ 8 - 8
F.cpp

@@ -1,14 +1,14 @@
-#include<bits/stdc++.h>
+#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;
+  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;
+  return 0;
 }

+ 6 - 6
F2.cpp

@@ -1,12 +1,12 @@
-#include<bits/stdc++.h>
+#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;
+  int a[3];
+  cin >> a[0] >> a[1] >> a[2];
+  sort(a, a + 3);
+  cout << a[0] << " " << a[1] << " " << a[2] << endl;
 
-    return 0;
+  return 0;
 }

+ 8 - 8
G.cpp

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

+ 13 - 14
H.cpp

@@ -1,17 +1,16 @@
-#include<bits/stdc++.h>
+#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;
-    }
+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;
+  return 0;
 }

+ 6 - 6
I.cpp

@@ -3,11 +3,11 @@
 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;
+  double F;
+  cin >> F;
+  cout << "F=" << fixed << F << endl;
+  double C = (F - 32) * 5 / 9;
+  cout << "C=" << fixed << C << endl;
 
-    return 0;
+  return 0;
 }