Merge pull request #19 from KiritoTRw/master

Contest 1151 Added.
This commit is contained in:
Kirigaya Kazuto 2016-05-26 07:41:19 +08:00
commit 58cac79dcc
12 changed files with 332 additions and 0 deletions

6
QUSTOJ/1740.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main()
{
printf("13\n");
return 0;
}

19
QUSTOJ/1741.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char a[1024];
char b[1024];
char c[1024];
int main()
{
gets(a);
gets(b);
int L=strlen(b);
int i;
for(i=0;i<L;i++)
{
c[L-1-i]=b[i];
}
printf("%s%s\n",a,c);
return 0;
}

34
QUSTOJ/1742.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
int a[4][4];
int main()
{
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("array a:\n");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
printf("array b:\n");
for(int i=3;i>=0;--i)
{
for(int j=0;j<4;j++)
{
printf("%d ",a[j][i]);
}
printf("\n");
}
return 0;
}

62
QUSTOJ/1744.c Normal file
View File

@ -0,0 +1,62 @@
#include <stdio.h>
int a[16];
int findmax()
{
int max=-(1e9);
int imax=-1;
for(int i=0;i<10;i++)
{
if(a[i]>max)
{
max=a[i];
imax=i;
}
}
return imax;
}
int findmin()
{
int min=1e9;
int imin=-1;
for(int i=0;i<10;i++)
{
if(a[i]<min)
{
min=a[i];
imin=i;
}
}
return imin;
}
void swap(int* a,int* b)
{
int tmp=*b;
*b=*a;
*a=tmp;
}
int main()
{
for(int i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
int iMax=findmax();
int iMin=findmin();
swap(&a[0],&a[iMax]);
swap(&a[iMin],&a[9]);
for(int i=0;i<5;i++)
{
printf("%d ",a[i]);
}
printf("\n");
for(int i=5;i<10;i++)
{
printf("%d ",a[i]);
}
return printf("\n"),0;
}

23
QUSTOJ/1745.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
int a[2048];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int i=n-m;i<n;i++)
{
printf("%d ",a[i]);
}
for(int i=0;i<n-m;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return 0;
}

23
QUSTOJ/1746.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
int a[11]={1,4,6,9,13,16,19,28,40,100,0};
int cmp(const void* a,const void* b)
{
return *(int*)a-*(int*)b;
}
int main()
{
int m;
scanf("%d",&m);
a[10]=m;
qsort(a,11,sizeof(int),cmp);
for(int i=0;i<11;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return 0;
}

29
QUSTOJ/1748.c Normal file
View File

@ -0,0 +1,29 @@
#include<stdio.h>
int a[20][20];
int main()
{
int n=0,i,j,k=1,p,q;
scanf("%d",&n);
i=0;
j=n/2;
for(p=0; p<n; p++)
{
for(q=0; q<n; q++)
{
if(q>0)
{
i=(i+n-1)%n;
j=(j+1)%n;
}
a[i][j]=k++;
}
i=(i+1)%n;
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
printf("%d ",a[i][j]);
printf("%d\n",a[i][n-1]);
}
return 0;
}

64
QUSTOJ/1750.c Normal file
View File

@ -0,0 +1,64 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[1024];
int b[1024];
int c[1024];
int cmp(const void* a,const void* b)
{
return *(int*)a-*(int*)b;
}
int main()
{
int n,m;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&m);
for(int i=0;i<m;i++)
{
scanf("%d",&b[i]);
}
qsort(a,n,sizeof(int),cmp);
qsort(b,m,sizeof(int),cmp);
int ia=0;
int ib=0;
int ic=0;
while(ia<n&&ib<m)
{
if(a[ia]==b[ib])
{
c[ic]=a[ia];
++ic;
++ia,++ib;
continue;
}
else if(a[ia]<b[ib])
{
++ia;
continue;
}
else if(a[ia]>b[ib])
{
++ib;
continue;
}
}
if(ic<1)
{
printf("空集\n");
return 0;
}
for(int i=0;i<ic-1;i++)
{
printf("%d ",c[i]);
}
return printf("%d\n",c[ic-1]),0;
}

28
QUSTOJ/1751.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int a[16];
int cmp(const void* a,const void* b)
{
return *(int*)a-*(int*)b;
}
int main()
{
for(int i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
qsort(a,10,sizeof(int),cmp);
for(int i=9;i>=0;--i)
{
printf("%d ",a[i]);
}
printf("\n");
int sum=0;
for(int i=1;i<9;i++)
sum+=a[i];
return printf("%.2f\n",(double)sum/8),0;
}

33
QUSTOJ/1752.c Normal file
View File

@ -0,0 +1,33 @@
#include <stdio.h>
#include <string.h>
char str[2048];
int iStack=0;
char stk[256][256];
int main()
{
gets(str);
int L=strlen(str);
for(int i=0;i<L;i++)
{
if(str[i]==','||str[i]=='.')
{
str[i]=' ';
}
}
char* p=str;
while(sscanf(p,"%s",stk[iStack])==1)
{
p=p+strlen(stk[iStack])+1;
iStack++;
}
for(int i=iStack-1;i>=0;--i)
{
printf("%s ",stk[i]);
}
return printf("\n"),0;
}

6
QUSTOJ/1763.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main()
{
return printf("8\n18\n"),0;
}

5
QUSTOJ/1764.c Normal file
View File

@ -0,0 +1,5 @@
#include <stdio.h>
int main()
{
return printf("最后的冠军是编号为2012的选手,他摘得水果的总重量是215kg\n"),0;
}