随笔分类 - 【hdoj】
摘要://hdoj 1062 Text Reverse 文本反转#include<iostream>#include<cstdio>#include<cstring>#include<cmath>char s[1000];using namespace std;int main(){ int n; int i,j,k; cin >> n; getchar(); for( i = 1;i <= n;i++){ j = 0; k = 1; s[j]=getchar(); while(s[j]!='\n'){ ...
阅读全文
摘要:#include<iostream>//#include<cmath>using namespace std;int main(){ int n,c1,c2,c3; double x; while( cin >> n && n != 0) { c1 = c2 = c3 = 0; for( int i = 0;i < n;i ++) { cin >> x; if( x < 0) { c1 ++; ...
阅读全文
摘要:#include<iostream>//#include<cmath>using namespace std;int main(){ double x,y; int n1,n2; while( cin >> n1 >> n2 ) { x = y = 0.0; if( n1 > n2) { swap(n1,n2); } for ( int i = n1;i <= n2;i ++) { if...
阅读全文
摘要:#include<iostream>//#include<cmath>using namespace std;int main(){ int n,x,sum; while( cin >> n ) { sum = 1; for( int i = 0;i < n;i ++) { cin >> x; if( x % 2 != 0) { sum *= x; } } ...
阅读全文
摘要:#include<iostream>//#include<cmath>using namespace std;int lev(int n){ if((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0)) { return 1; } else return 0; } int main(){ int month[2][13]= {{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,3...
阅读全文
摘要:#include<iostream>using namespace std;#define max 9int main(){ int Array[max]; /*for ( int i = 0;i < max;i ++) { Array[i] = max - i; }*/ cout <<"原始数据:"; for ( int i = 0;i < max;i ++) { cin >> Array[i]; } cout << endl; ...
阅读全文
摘要:#include<iostream>#include<cmath>using namespace std;int main(){ int x; while( cin >> x) { if( x < 0 || x > 100) { cout << "Score is error !" << endl; } else if( x >= 90) { cout << "A" << endl; ...
阅读全文
摘要:#include<iostream>#include<cmath>using namespace std;int main(){ double x; cout.precision(2); while( cin >> x) { cout << fixed << fabs(x) << endl; } system("pause"); }
阅读全文
摘要:#include<iostream>#include<cmath>using namespace std;int main(){ const double pi = 3.1415926; double x; cout.precision(3); while( cin >> x ) { cout << fixed << 4*pi*pow(x,3)/3 << endl; } system("pause"); }
阅读全文
摘要:#include<iostream>#include<cmath>using namespace std;int main(){ double x1,y1,x2,y2; cout.precision(2); while( cin >> x1 >> y1 >> x2 >> y2) { cout << fixed << sqrt(pow((x1-x2),2)+pow((y1-y2),2)) << endl; } system("pause"); }
阅读全文
摘要:#include<iostream>using namespace std;int main(){ char a[4]; while(cin >> a) { /*for( int i = 0;i < 3;i ++) { cin >> a[i]; }*/ if( a[0] > a[1]) swap(a[0],a[1]); if(a[1] > a[2]) swa...
阅读全文
摘要:/*/解决本题的关键:通过公式条件:F(0)= 7, F(1) = 11,F(n) = F(n-1) + F(n-2) (n>=2). 找到规律。由同余式的基本性质:(1)自反性:a = a( mod m)。以及同余式的四则运算法则:(1)如果 a =b( mod m)且 c = d( mod m),则 a +c = (b + d)( mod m)。可知,F(n) = F(n) ( mod m) = ( F(n-1) +F(n-2) )( mod m)。根据题目已知条件:Print the word"yes" if 3 divide evenly into F(n);
阅读全文
摘要:#include<iostream>using namespace std;/*int gcd( int a,int b){ int r = 0; while(b!=0) { r = a%b; a = b; b = r; } return a; } */int gcd( int a,int b){ if(b==0) { return a; } else ...
阅读全文