标签:ret i++ return etl 乙级 upper end sed a*
//1
////字符中可能有0-9以外的字符,这时就直接打印输出并输入下一个!!!!
#include<bits/stdc++.h>
using namespace std;
int s[18]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char z[12]={‘1‘,‘0‘,‘X‘,‘9‘,‘8‘,‘7‘,‘6‘,‘5‘,‘4‘,‘3‘,‘2‘};
int main(){
int n;
scanf("%d",&n);
int m=n;
char a[18];
int cnt=0;
while(n--){
cin>>a;
char c=a[17];
int flag=1;
for(int j=0;j<17;j++){
if(a[j]<‘0‘||a[j]>‘9‘)
flag=0;
}
if(flag==0){
printf("%s\n",a);
continue;
}
int sum=0;
for(int j=0;j<17;j++){
sum+=(a[j]-‘0‘)*s[j];
}
if(z[sum%11]!=c){
printf("%s\n",a);
}else{
cnt++;
}
}
if(cnt==m)
printf("All passed");
return 0;
}
//2
#include<bits/stdc++.h>
using namespace std;
int s[100010]={0};
int main(){
int n;
scanf("%d",&n);
int a,b;
while(n--){
scanf("%d %d",&a,&b);
s[a]+=b;
}
int max=s[0],p=0;
for(int i=1;i<100010;i++){
if(s[i]>max){
p=i;
max=s[i];
}
}
printf("%d %d",p,max);
return 0;
}
//3
////find真的好用啊呜呜呜呜
#include<bits/stdc++.h>
using namespace std;
int main(){
string bad,should;
getline(cin, bad); ////cin遇到空白符会终止,所以用getline()
getline(cin, should);
for(int i=0;i<should.length();i++){
if(bad.find(toupper(should[i]))!=string::npos) continue;
if(isupper(should[i])&&bad.find(‘+‘)!=string::npos ) continue;
cout<<should[i];
}
return 0;
}
//4
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
long long gcd(long long t1,long long t2){
return t2==0?t1:gcd(t2,t1%t2);
}
void func(long long m,long long n){
if(m*n==0){
printf("%s",n==0?"Inf":"0");
return;
}
bool flag=((m>0&&n<0)||(m<0&&n>0));
m=abs(m);n=abs(n);
long long x=m/n;
printf("%s",flag?"(-":"");
if(x!=0) printf("%lld",x);
if(m%n==0){
printf("%s",flag?")":"");
return ;
}
if(x!=0) printf(" ");
m=m-x*n;
long long t=gcd(m,n);
m/=t;n/=t;
printf("%lld/%lld%s",m,n,flag?")":"");
return;
}
int main(){
scanf("%lld/%lld %lld/%lld",&a,&b,&c,&d);
func(a,b);printf(" + ");func(c,d);printf(" = ");func(a*d+c*b,b*d);printf("\n");
func(a,b);printf(" - ");func(c,d);printf(" = ");func(a*d-c*b,b*d);printf("\n");
func(a,b);printf(" * ");func(c,d);printf(" = ");func(a*c,b*d);printf("\n");
func(a,b);printf(" / ");func(c,d);printf(" = ");func(a*d,b*c);return 0;
}
//5
//////// https://www.liuchuo.net/archives/503
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,i,j;
cin>>n;
int a[n],b[n];
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n-1&&b[i]<=b[i+1];i++);
for(j=i+1;j<n&&a[j]==b[j];j++);
if(j==n){
cout<<"Insertion Sort"<<endl;
sort(a,a+i+2);
}else{
cout<<"Merge Sort"<<endl;
int k=1,flag=1;
while(flag){
flag=0;
for(i=0;i<n;i++){ ///对原来的序列模拟归并
if(a[i]!=b[i])
flag=1;
}
k=k*2;
for(i=0;i<n/k;i++)
sort(a+i*k,a+(i+1)*k);
sort(a+n/k*k,a+n);
}
}
for(i=0;i<n;i++){
if(i!=0) printf(" ");
printf("%d",a[i]);
}
return 0;
}
标签:ret i++ return etl 乙级 upper end sed a*
原文地址:https://www.cnblogs.com/suying/p/10409280.html