-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrequency_1.fprg
53 lines (53 loc) · 2.69 KB
/
frequency_1.fprg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version="1.0"?>
<flowgorithm fileversion="2.11">
<attributes>
<attribute name="name" value=""/>
<attribute name="authors" value="crossover"/>
<attribute name="about" value=""/>
<attribute name="saved" value="2022-01-17 08:21:21 PM"/>
<attribute name="created" value="Y3Jvc3NvdmVyO0dBVFRBTUFORU5JU0FJUjsyMDIyLTAxLTE3OzAzOjE2OjU3IFBNOzMzOTE="/>
<attribute name="edited" value="Y3Jvc3NvdmVyO0dBVFRBTUFORU5JU0FJUjsyMDIyLTAxLTE3OzA4OjIxOjIxIFBNOzM7MzQ5Mw=="/>
</attributes>
<function name="Main" type="None" variable="">
<parameters/>
<body>
<output expression=""please enter the size of the array"" newline="True"/>
<declare name="n, i, j, t" type="Integer" array="False" size=""/>
<input variable="n"/>
<declare name="ar" type="Integer" array="True" size="n"/>
<output expression=""please enter the elements of the array"" newline="True"/>
<for variable="i" start="0" end="n-1" direction="inc" step="1">
<input variable="ar[i]"/>
</for>
<for variable="i" start="1" end="n-1" direction="inc" step="1">
<for variable="j" start="0" end="n-i-1" direction="inc" step="1">
<if expression="ar[j]>ar[j+1]">
<then>
<assign variable="t" expression="ar[j]"/>
<assign variable="ar[j]" expression="ar[j+1]"/>
<assign variable="ar[j+1]" expression="t"/>
</then>
<else/>
</if>
</for>
</for>
<declare name="ele, freq" type="Integer" array="False" size=""/>
<assign variable="ele" expression="ar[0]"/>
<assign variable="freq" expression="1"/>
<declare name="q" type="Integer" array="False" size=""/>
<for variable="i" start="1" end="n-1" direction="inc" step="1">
<if expression="ar[i]==ele">
<then>
<assign variable="freq" expression="freq+1"/>
</then>
<else>
<output expression=""the frequency of "&ele&" is "&freq" newline="True"/>
<assign variable="freq" expression="1"/>
<assign variable="ele" expression="ar[i]"/>
</else>
</if>
</for>
<output expression=""the frequency of "&ele&" is "&freq" newline="True"/>
</body>
</function>
</flowgorithm>