Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #include "types/list.h"
- #include "types/types.h"
- list* f1(list* lista){
- int i;
- list lista2 = list_empty(int_type);
- for(i=0; i<lista->size; i++){
- if(((*(int*) list_get(lista, i)))%2==0){
- int x = *(int*)list_get(lista, i);
- x=x*x;
- list_add(&lista2, &x);
- }
- }
- return &lista2;
- }
- int main(){
- int listita[] = {1,2,3,4,5,6};
- list lista = list_of(listita, 6, int_type);
- char* mem = malloc(sizeof(list));
- printf("%s\n", list_tostring((f1(&lista)), mem));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement