标签:%s for main turn stdin pac scan csp +=
#include<iostream> #include<cstdio> #define maxn 100010 using namespace std; int a[maxn],n; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); int x,z; double y; x=a[1];z=a[n]; if(x<z)swap(x,z); printf("%d ",x); if(n%2==0){ y=(double)(a[n/2]+a[n/2+1])/2.0; } else { y=a[n/2+1]; } if(y==(int)y)printf("%.0f ",y); else printf("%.1f ",y); printf("%d\n",z); return 0; }
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,st[10],top; char s[10]; int main(){ freopen("Cola.txt","r",stdin); scanf("%d",&n); while(n--){ top=0; scanf("%s",s+1); int pre=1; for(int i=1;i<=7;i++){ if(s[i]<=‘9‘&&s[i]>=‘1‘){ int a=s[i]-‘0‘; st[++top]=pre*a; } else{ if(s[i]==‘+‘)pre=1; else if(s[i]==‘-‘)pre=-1; else if(s[i]==‘x‘){ int b=s[i+1]-‘0‘; int a=st[top]; st[top]=a*b; i++; } else{ int b=s[i+1]-‘0‘; int a=st[top]; st[top]=a/b; i++; } } } int ans=0; for(int i=1;i<=top;i++)ans+=st[i]; // printf("%d\n",ans); if(ans==24){puts("Yes");} else {puts("No");} } return 0; }
标签:%s for main turn stdin pac scan csp +=
原文地址:https://www.cnblogs.com/thmyl/p/12041460.html