删除重复的行 [英] Removing repeated rows
问题描述
我想删除数字组合中重复的行。
我已经发布了代码。请运行,看看。
提前感谢
我的尝试:
i want to remove the repeated rows in the combinations of numbers.
i have posted code for that. please run that and see.
thanks in advance
What I have tried:
#include<stdio.h>
int main()
{
int arr[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int i,j=9,x;
while(j>0)
{
for (i=1; i<9; i++)
{
for(x=0;x<9;x++)
{
if (x!= j&&x!=i)
{
printf("%d",arr[x]);
}
else
{
printf("*");
}
}
printf("\n");
}
j--;
printf("\n");
}
return 0;
}
推荐答案
这听起来像是我的作业...
我会给你一个提示:在创建组合时,将它们存储在一个新的数组中。然后你有一个你已经创建的内容的参考,可以比较以确定它是否是一个独特的组合。
This sounds like homework to me...
I'll give you a tip: As you create your combinations, store them in a new array. Then you have a reference of what you have already created and can compare against to determine whether it is a unique combination or not.
我们不做你的HomeWork,所以只有建议。 />
We do not do your HomeWork, so only advices.
我想删除数字组合中重复的行。
i want to remove the repeated rows in the combinations of numbers.
- 优化删除重复行的定义,因为这不是你的代码。
显示你想要的输出和输出的例子。
- 您是否注意到您的阵列没有重复行?
要测试删除重复行的程序,最好是拥有重复行的数据样本。
- 在程序中每个位置都硬编码数组的大小是一个坏主意,因为每次你改变大小数组,你必须在每个地方改变代码。用它来存储变量中的大小。
- Refine definition of "remove the repeated rows", as this is not what is doing your code.
Show example of output you want and output you get.
- Did you noticed that your array do not have "repeated rows"?
To test a program that "remove the repeated rows", it is a good idea to have data sample that have "repeated rows".
- Having the size of array hardcoded every where in program is a bad idea, because every time you change the size of array, you have to change code every where. Usage it to store the size in a variable.
这篇关于删除重复的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!