# 2019西工大机试题全

2

2 1 3 5 4 6 7 8

11 33 44 22 55 77 66 88

1 2 3 4 5 6 7 8

11 22 33 44 55 66 77 88

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,i=0;
cin>>n;
while(i<n)
{
int b[8]={0};
for(int j=0;j<8;j++)
{ cin>>b[j];}
for(int j=0;j<8;j++)
{
sort(b,b+8);
cout<<b[j];

}
i++;
cout<<""<<endl;
}

return 0;
}

2

1 2 3

4 5 6

NaN

6

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
double a,b,c,s,p;
int i=0,n;
cin>>n;
while(i<n)
{
i++;
cin>>a>>b>>c;
if(a+b>c&&a+c>b&&b+c>a)
{
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<s<<endl;
}
else
cout<<"NaN"<<endl;
}
return 0;
}

2

1.2.3.4

2222.3.4.5

yes

no

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<cstring>
using namespace std;
void  judge(int *a)
{   int k=1;
for(int i=0;i<4;i++)
{
if(255<a[i]||a[i]<0)
k=0;
}
if(k==1) cout<<"yes"<<endl;
else if(k==0) cout<<"NO"<<endl;
}
int main()
{
char s[100];
int i=0,n;
cin>>n;
while(i<n)
{

cin>>s;
int a[4]={0},j=0,num=0,l=strlen(s)-1;
while(l>=0)
{
if(s[l]!='.'&&l>=0)
{
a[j]+=(s[l]-'0')*pow(10,num);
num++;
}
if(s[l]=='.')
{
j++;
num=0;
}
l--;
}
i++;
int *p=a;
judge(p);

}
return 0;

}

#include<iostream>
#include<cstdio>
using namespace std;
int judge(int a)
{
int k=1;
for(int i=2;i<a;i++)
{
if(a%i==0)
k=0;
}
return k;
}
int main()
{
int a,b,sum=0,i=0,j=0;
cin>>a>>b;
for(i=a;j<b;i++)
{
if(judge(i)==1)
{
cout<<i<<" ";j++;
}
}
return 0;

}

2019 1  1  2019 1 2

2016 1 1 2016  3 1

2

61

#include<iostream>
#include<cstdio>
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int day1[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int judge(int a,int b,int c)
{
int sum=c;
if(a%400==0||(a%4==0&&a%100!=0))
{
for(int i=1;i<b;i++)
sum+=day1[i];
}
else
{
for(int i=1;i<b;i++)
sum+=day[i];
}
return sum;

}
int main()
{
int k=0,n;
cin>>n;
while(k<n)
{
int y,m,d,y1,m1,d1;
cin>>y>>m>>d>>y1>>m1>>d1;
cout<<judge(y1,m1,d1)-judge(y,m,d)+1<<endl;
k++;
}
return 0;
}

06-26
06-27
11-17 1828
03-25 3103
05-02 1456
03-23 279
01-25 269
03-30 468
03-12 386
03-10 1333
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客