This commit is contained in:
xice09
2018-07-31 23:21:54 +08:00
parent 36e132edbc
commit 36f2ab51ab
10 changed files with 176 additions and 0 deletions

17
2000.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;
void c(char &a,char &b){
char t = a;
a = b;
b = t;
}
int main(){
char a[4];
while(cin >> a){
if(a[0]>a[1])c(a[0],a[1]);
if(a[1]>a[2])c(a[1],a[2]);
if(a[0]>a[1])c(a[0],a[1]);
cout << a[0] << " " << a[1] << " " << a[2] << endl;
}
return 0;
}

12
2001.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
double a1,a2,b1,b2,o;
while(cin>>a1>>a2>>b1>>b2){
o = sqrt(pow(a1-b1,2)+pow(a2-b2,2));
cout << setiosflags(ios::fixed) << setprecision(2) << o << endl;
}
return 0;
}

13
2002.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#define PI 3.1415927
#include <cmath>
using namespace std;
int main(){
double a,o;
while(cin>>a){
o = 4.0 / 3.0 * PI * pow(a,3);
cout << setiosflags(ios::fixed) << setprecision(3) << o << endl;
}
return 0;
}

11
2003.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double a;
while(cin>>a){
a = a>0?a:-a;
cout << setiosflags(ios::fixed) << setprecision(2) << a << endl;
}
return 0;
}

21
2004.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a;
while(cin>>a){
if(a>100 || a<0)
cout << "Score is error!" << endl;
else if (a > 89)
cout << "A"<<endl;
else if (a > 79)
cout << "B" << endl;
else if (a > 69)
cout << "C" << endl;
else if (a > 59)
cout << "D" << endl;
else
cout << "E" << endl;
}
return 0;
}

35
2005.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#define IS_LEAP_YEAR(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
#define TO_INT(x) ((int)(x)-48)
using namespace std;
int main(){
char a[10];
int y,m,d,o;
while(cin>>a){
y = TO_INT(a[0])*1000+TO_INT(a[1])*100+TO_INT(a[2])*10+TO_INT(a[3]);
if(a[6] == '/'){
m = TO_INT(a[5]);
d = a[8] == '\0'?TO_INT(a[7]):(TO_INT(a[7])*10+TO_INT(a[8]));
} else{
m = TO_INT(a[5])*10+TO_INT(a[6]);
d = a[9] == '\0'?TO_INT(a[8]):(TO_INT(a[8])*10+TO_INT(a[9]));
}
switch (m){
case 12:d += 30;
case 11:d += 31;
case 10:d += 30;
case 9:d += 31;
case 8:d += 31;
case 7:d += 30;
case 6:d += 31;
case 5:d += 30;
case 4:d += 31;
case 3:d += IS_LEAP_YEAR(y)?29:28;
case 2:d += 31;
default:break;
}
cout << d << endl;
}
return 0;
}

14
2006.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main(){
int a,b,o;
while(cin>>a){
o = 1;
for(int i = 0;i<a;i++){
cin >> b;
o *= b%2==0?1:b;
}
cout << o <<endl;
}
return 0;
}

19
2007.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include <iostream>
#include <cmath>
#define lint long long
using namespace std;
int main(){
lint a,b,o1,o2;
while(cin>>a>>b){
o1 = 0,o2 = 0;
if(a>b)a^=b^=a^=b;
for(;a<=b;a++){
if(a%2 == 0)
o1 += pow(a,2);
else
o2 += pow(a,3);
}
cout << o1 << ' ' << o2 << endl;
}
return 0;
}

20
2008.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
int main(){
int a,b,c,n;
double t;
while(cin>>n && n>0){
a = b = c = 0;
for(int i=0;i<n;i++){
cin >> t;
if(t<0)
a++;
else if (t>0)
c++;
else
b++;
}
cout << a << ' ' << b << ' ' << c << endl;
}
return 0;
}

14
2009.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
double a,n,o;
while(cin>>a>>n){
o = a;
for(int i =0;i<n-1;i++)
o += a=sqrt(a);
cout << setiosflags(ios::fixed) << setprecision(2) << o << endl;
}
return 0;
}