2014-11-19から1日間の記事一覧

10029 - Sort II

#include <algorithm> #include <iostream> using namespace std; void Slove(int n) { int data[n]; for (int i=0; i<n; ++i) cin >> data[i]; sort(data,data+n); for (int i=0; i<n; ++i) (i==0)? cout << data[i] : cout << " " << data[i]; cout << endl; } int main(void) { int n; while (cin >> n && n) Slove(n); …</n;></n;></iostream></algorithm>

10028 - Sort I

#include <algorithm> #include <iostream> using namespace std; void Slove(int n) { int data[n]; for (int i=0; i<n; ++i) cin >> data[i]; sort(data,data+n); for (int i=0; i<n; ++i) (i==0)? cout << data[i] : cout << " " << data[i]; cout << endl; } int main(void) { int n; while (cin >> n && n) Slove(n); …</n;></n;></iostream></algorithm>

10027 - Card Game

#include <iostream> #include <string> using namespace std; void Slove(int n) { int tarou_point=0, hanako_point=0; string tarou_card, hanako_card; for (int i=0; i<n; ++i) { cin >> tarou_card >> hanako_card; if (tarou_card > hanako_card) tarou_point+=3; else if (tarou_card <</n;></string></iostream>…

10026 - Standard Deviation

#include <cmath> #include <cstdio> #include <iostream> using namespace std; void Slove(int n) { int s[n]; double m, variance=0.0; for (int i=0; i<n; ++i) { cin >> s[i]; m+=s[i]; } m/=n; for (int i=0; i</n;></iostream></cstdio></cmath>

10025 - Triangle

#include <cmath> #include <cstdio> #include <iostream> using namespace std; void Slove(double a, double b, double angle) { double rad=(angle/180)*M_PI; double S=a*b*sin(rad)/2; double L=a+b+sqrt( pow(a,2)+pow(b,2)-2*a*b*cos(rad) ); double h=b*sin(rad); printf ("%.</iostream></cstdio></cmath>…

10024 - Distance

#include <cmath> #include <cstdio> #include <iostream> using namespace std; void Slove(double x1, double y1, double x2, double y2) { printf ( "%.8lf\n", sqrt( pow(x2-x1,2)+pow(y2-y1,2) ) ); } int main(void) { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; Slo</iostream></cstdio></cmath>…

10023 - Shuffle

#include <iostream> #include <string> using namespace std; void Slove(string str) { int m, h; cin >> m; for (int i=0; i<m; ++i) { cin >> h; str=str.substr(h)+str.substr(0,h); } cout << str << endl; } int main(void) { string str; cin >> str; while (str != "-") { Slove(str);</m;></string></iostream>…

10022 - Finding a Word

#include <cctype> #include <iostream> #include <string> using namespace std; string Change(string str) { for (int i=0; i<str.length(); ++i) if ( isupper(str[i]) ) str[i]=tolower(str[i]); return str; } void Slove(string W) { int answer=0; string T; cin >> T; while(T != "END_OF_TEXT") { if (Change(T) …</str.length();></string></iostream></cctype>