标签:else str lse += sort i++ std oid 测试
题目:思路:
能用最差的马弄对面最差的马就用最差的马 否则用最差的马换对方最好的马。
代码
#include <stdio.h>
//用了排序方便处理
void sort(int *a, int left, int right)
{
if (left >= right)
{
return;
}
int i = left;
int j = right;
int key = a[left];
while (i < j)
{
while (i < j && key <= a[j])
{
j--;
}
a[i] = a[j];
while (i < j && key >= a[i])
{
i++;
}
a[j] = a[i];
}
a[i] = key;
sort(a, left, i - 1);
sort(a, i + 1, right);
}
int main()
{
int SL = 0;
int XHBL = 0;
int DYFS = 0;
int *DYZZ = 0;
int *DEZZ = 0;
int *DEJWZZ = 0;
int DIYIZU[10] = { 0 };
int DIERZU[10] = { 10 };
scanf("%d",&SL);
for (XHBL = 0; XHBL < SL; XHBL++)
scanf("%d", &DIYIZU[XHBL]);
for (XHBL = 0; XHBL < SL; XHBL++)
scanf("%d", &DIERZU[XHBL]);
sort(DIYIZU,0, SL-1);
sort(DIERZU,0, SL-1);
DYZZ = &DIYIZU[0];
DEZZ = &DIERZU[0];
DEJWZZ = &DIERZU[SL - 1];
for (XHBL=0;XHBL<SL;XHBL++)
{
if (*DYZZ >= *DEZZ) //这里是如果两马速度相等就打平还是齐王赢? 这里算作平等
{
if(*DYZZ!= *DEZZ)
DYFS += 200;
DYZZ++;
DEZZ++;
}
else
{
DEJWZZ--;
DYZZ++;
DYFS -= 200;
}
}
printf("Tianji InTotal:%d", DYFS);
return 0;
}
标签:else str lse += sort i++ std oid 测试
原文地址:http://blog.51cto.com/3458905/2314433