I'm having a hard time resolving a C exercise, I've never programmed it, and I've taken C in the first semester, can you help?
- I need to sort out 3 integer values between 0 and 200 in the main function.
- If the value is Par, I need to put the right in the simple list chained - function List_of_Right
- If the value is odd, I need to put the left one in the single linked list - Left_List function. NOTE: There are two lists, it is just a list, At the end the list will be divided: at the beginning of the odd and at the end the pairs.
- Then I need to create a function to find the largest value in the list and return the value to the main function
- Then I need to multiply all the values in the list by the greatest value
- After that, just print the list.
I was able to play a part, with a lot of difficulty, and there are still parts left. Could you please help me? Here's a part of my code.
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<conio.h>
#define TAM 3
//Declaração da struct nodo
struct nodo
{
int dados;struct nodo *prox;
}
//Função principal
int main()
{
struct nodo *ptri=NULL;
int x,nro,maior;
for(x=0;x<TAM;x++)
{
nro=rand()%201;
//função de sorteio
//aqui deve ser implementada a verificação
//do par e ímpar para inserir na lista, porém não sei como fazer essa comparação, tentei de várias formas o if e sempre da erro
} //fim do for
printf("\n\n---LSE---\n\n");
ImprimeLSE(&ptri); //Função de impressão
maior= PesquisaMaior(&ptri);
printf("\n\n---LSE-Maior = %i---\n\n",maior);
ImprimeLSE(&ptri); //Função de impressão
MultiplicaLSE(maior,&ptri);
printf("\n\n---LSE Multiplicado por %i---\n\n",maior);
ImprimeLSE(&ptri); //Função de impressão
getch();
} //fim da função