AC代碼ios
#include<iostream> using namespace std; int a[100]; int n, c1 = 0, c5 = 0, c10 = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1)c1++; if (a[i] == 5)c5++; if (a[i] == 10)c10++; } cout << c1 << endl; cout << c5 << endl; cout << c10 << endl; return 0; }
AC代碼less
#include<iostream> using namespace std; int main() { char s[205]; gets(s); int b = 0; for(int i=0;s[i]!=0;i++) { if(s[i]==' ') { if(b==0)cout<<' '; b=1; } else{ cout<<s[i]; b = 0; } } cout<<endl; return 0; }
AC代碼spa
#include<cstdio> #include<queue> #include<iostream> using namespace std; priority_queue<double, vector<double>, greater<double> >man; priority_queue<double, vector<double>, less<double> >woman; int main() { int n; scanf("%d", &n); char sex[10]; double x; for (int i = 0; i < n; i++) { scanf("%s%lf", sex, &x); if (sex[0] == 'm')man.push(x); if (sex[0] == 'f')woman.push(x); } while (!man.empty()) { x = man.top(); man.pop(); printf("%.2lf ", x); } while (!woman.empty()) { x = woman.top(); woman.pop(); if(woman.empty())printf("%.2lf", x); else printf("%.2lf ", x); } printf("\n"); return 0; }