C 递归链表?我想
我是个新手,我很难理解学习如何有效编码所需的宏步骤。这些作业感觉非常抽象,在我做之前,我必须学习递归的所有知识。编写一个程序并不容易,可以说,当有人“帮助我在蛋黄酱和芥末之间徘徊”时,我做得非常好。我做错了什么?我需要朝着什么方向继续 我在想,我需要先对列表进行排序,然后根据分配使用两个单独的函数进行合并排序和插入排序: 在这场大流行中,你们大部分时间都呆在家里。对人们来说,最重要的是要知道其他人在哪里,他们在哪里 感染了新冠病毒的人是谁,他们与谁有过接触。保持 此信息的跟踪称为“联系人跟踪” 你听说过可能会有一些高薪的工作 如果您能向客户展示您的合同跟踪技能 政府,所以你决定写一个小程序来强调 这些技能。你的区域可以在笛卡尔平面上建模。你是 位于点(x,y)处。此外,还有笛卡尔坐标 目前感染新冠病毒-19的所有人的坐标。 您想做的是编写一个程序,对 这些位置基于它们与您的距离,然后是 处理查询。这些查询的形式为您正在查询的点 想去看看。您的程序应该识别 被感染的人就在那个地方,如果是的话,他们的排名是多少 已分类的感染者名单。如果当时没有人被感染 在那个位置,你应该正确地识别这个 注意:此任务有许多重要的实现限制,因此为了确保每个人都阅读这些限制,请参阅 下一步将是实施限制,更改 与其他作业相比的部分 实施限制C 递归链表?我想,c,C,我是个新手,我很难理解学习如何有效编码所需的宏步骤。这些作业感觉非常抽象,在我做之前,我必须学习递归的所有知识。编写一个程序并不容易,可以说,当有人“帮助我在蛋黄酱和芥末之间徘徊”时,我做得非常好。我做错了什么?我需要朝着什么方向继续 我在想,我需要先对列表进行排序,然后根据分配使用两个单独的函数进行合并排序和插入排序: 在这场大流行中,你们大部分时间都呆在家里。对人们来说,最重要的是要知道其他人在哪里,他们在哪里 感染了新冠病毒的人是谁,他们与谁有过接触。保持 此信息的跟踪称为“联系人跟踪”
x y found at rank R
x y not found
0 0 14 5 53
1 -6
-2 -4
3 4
-4 2
4 -1
3 2
2 0
-5 -4
-2 -6
6 4
4 -2
4 0
5 -4
6 2
-13 1
0 -5
#include <stdio.h>
int x = 0;//global coordinates
int y = 0;
typedef struct {
int xInput, yInput;
}coordinates;
void scanPoints(coordinates[], int infectedPeople);
void scanSearchValues(coordinates[], int pointsToSearch);
void SortPoints(coordinates[], int);
int lessThan(coordinates[], int, int);
void printPoints(coordinates[], int);
void
scanPoints(coordinates pts[], int infectedPeople){
for (int i = 0; i < infectedPeople; i++){
scanf("%d %d", &pts[i].xInput, &pts[i].yInput);
}
}
void
scanSearchValues(coordinates pts[], int pointsToSearch){
for (int i = 0; i < pointsToSearch; i++){
scanf("%d %d", &pts[i].xInput, &pts[i].yInput);
}
}
void
sortPoints(coordinates pts[], int infectedPeople){
int i, start, min_index, temp;
for (start = 0; start < infectedPeople - 1; start++) {
min_index = start;
for (i = start + 1; i < infectedPeople; i++) {
if (lessThan(pts, i, min_index)) {
min_index = i;
}
}
if (min_index != start) {
coordinates temp = pts[start];
pts[start] = pts[min_index];
pts[min_index] = temp;
}
}
}
int
lessThan(coordinates pts[], int p, int q) {
if ((pts[p].xInput < pts[q].xInput) || ((pts[p].xInput == pts[q].xInput) && (pts[p].yInput < pts[q].yInput))) {
return 1;
}
}
int
main(int argc, const char * argv[]) {
int infectedPeople;
int pointsToSearch;
int threshold;
scanf("%d%d", &x, &y);
if(x > 10000 || y > 10000 )
return 0;
scanf("%d", &infectedPeople);
if(infectedPeople < 2 || infectedPeople > 1000000)
return 0;
scanf("%d", &pointsToSearch);
if(pointsToSearch < 1 || pointsToSearch > 200000)
return 0;
scanf("%d", &threshold);
if(threshold < 1 || threshold > 30)
return 0;
return 0;
}
int
lessThan(coordinates pts[], int p, int q) {
if ((pts[p].xInput < pts[q].xInput) || ((pts[p].xInput == pts[q].xInput) && (pts[p].yInput < pts[q].yInput))) {
return 1;
}
}
int lessThan(coordinates pts[], int p, int q)
{
return ((pts[p].xInput < pts[q].xInput) || ((pts[p].xInput == pts[q].xInput) && (pts[p].yInput < pts[q].yInput)));
}
void sortCoordinates(coordinates coords[], int count, int threshold) {
if (/* your condition here */) {
insertionSortCoordinates(coords, count);
} else {
mergeSortCoordinates(coords, count);
}
}
int compareTo(coordinates *ptrPt1, coordinates *ptrPt2) {
/* your code here */
}
int binarySearch(coordinates *target, coordinates coords[]) {
/* your code here: returns 1-based rank if found, zero if not found */
}