如何使用freemarker删除数组中的重复元素? [英] How to remove duplicate elements in a array using freemarker?

查看:508
本文介绍了如何使用freemarker删除数组中的重复元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了用于在C中查找重复元素的代码,但现在我被困在在freemarker中实现相同代码的人吗?

I had written the code for finding duplicate elements in C but now I am stuck at implementing the same code in freemarker Can anyone help?

int n, a[10], b[10], count = 0, c, d;

   printf("Enter number of elements in array\n");
   scanf("%d",&n);

   printf("Enter %d integers\n", n);
   for(c=0;c<n;c++)
      scanf("%d",&a[c]);

   for(c=0;c<n;c++)
   {
      for(d=0;d<count;d++)
      {
         if(a[c]==b[d])
            break;
      }
      if(d==count)
      {
         b[count] = a[c];
         count++;
      }
   }

   printf("Array obtained after removing duplicate elements\n");         
   for(c=0;c<count;c++)
      printf("%d\n",b[c]);

推荐答案

您可以使用自由标记序列.可能效率不是很高,但是我已经使用它来对接近发票等的最大尺寸线进行分组.

You can use freemarker sequences. Probably not super efficient but I've used this to group close to max size lines on invoices and such.

<#assign seen_style = []>
<#list record.item?sort_by("custcol_stylesort")  as lineitem>
   <#assign groupId = lineitem.item>
   <#if seen_style?seq_contains(groupId)> <!-- no if body is intentional; skips seen style -->
   <#else>
     <#assign seen_style = seen_style + [groupId]>
     <p>Do something with ${groupId}</p>
   </#if>
</#list>

这篇关于如何使用freemarker删除数组中的重复元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆