INDAPlus21 / INDAPlus21/murnion-task-7
Pass
- Dominant language
- C
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Very well done Felix!**
**_Note_**: I will from this correction demand readable code. You are allowed to make art if that art is supplemented with proper formatted code, such as:
_Artsy code file_:
```c
// mmm ... donuts
%:include/*!ioccc*/
%:include/*#include*/
int c(const void *a, const void *b)//plåg:
<%const int *ia = (const int *)a;//casting??\
types const // int main() <% int a,aa,ab;
ab=0;scanf/**/ ("%d", &a);/**/
aa=(a%2== 0) ? a/2 : (a+1) /2;
/*printf("%d\n ",aa);int y=a*/
int*b = malloc (a*sizeof(int));
for(int i=0;i
qsort((void *)b, a, sizeof(int), c); for
(int i=0;i
printf("%d\n",ab);%>
```
_Readable code file_:
```c
%:include
%:include
int c (const void *a, const void *b)
<%
const int *ia = (const int *)a;
const int *ib = (const int *)b;
return *ib - *ia;
%>
int main()
<%
int a, aa, ab;
ab = 0;
scanf("%d", &a);
aa = (a%2 == 0) ? a/2 : (a+1)/2;
int *b = malloc(a * sizeof(int));
for (int i = 0; i < a; i++)
<%
scanf("%d", &b[i]);
%>
qsort((void*)b, a, sizeof(int), c);
for (int i = 0; i < aa; i++)
<%
ab += b[i];
%>
printf("%d\n", ab);
%>
```
Don't missunderstand; I was quite amused by your formatting in class.
Here are some notes on your code:
#### Summera tal
Why heap allocation in `summera_tal.c`. Stack allocation is only dangerous if a pointer to such data is returned from the procedure in questioned, not if the pointer is used as argument. Yes, some IDE C-extensions will give warnings for non-constant stack allocation sizes, but such are allowed by the ISO C99 standard. The ISO C90 standard however whould, in case of `int b[a];`, produce:
```
summera_tal/main.c: In function ‘main’:, not dynamic array.
summera_tal/main.c:15: warning: ISO C90 forbids variable length array ‘a’
```
Contributor guide
No contributing guide indexed for this repository
Research direction
This is a review note rather than a defined task, and it mentions summera_tal.c and summera_tal/main.c. Read those files and determine whether a concrete readability or allocation change is intended; completion cannot be verified from this issue alone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100