{"action":"created","issue":{"url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/2","labels_url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/2/comments","events_url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/2/events","html_url":"https://github.com/bcc-ufg-ed1/PilhaEnc/issues/2","id":73982939,"number":2,"title":"Obter quantidade de elementos","user":{"login":"pauloafpjunior","id":5550053,"avatar_url":"https://avatars.githubusercontent.com/u/5550053?v=3","gravatar_id":"","url":"https://api.github.com/users/pauloafpjunior","html_url":"https://github.com/pauloafpjunior","followers_url":"https://api.github.com/users/pauloafpjunior/followers","following_url":"https://api.github.com/users/pauloafpjunior/following{/other_user}","gists_url":"https://api.github.com/users/pauloafpjunior/gists{/gist_id}","starred_url":"https://api.github.com/users/pauloafpjunior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauloafpjunior/subscriptions","organizations_url":"https://api.github.com/users/pauloafpjunior/orgs","repos_url":"https://api.github.com/users/pauloafpjunior/repos","events_url":"https://api.github.com/users/pauloafpjunior/events{/privacy}","received_events_url":"https://api.github.com/users/pauloafpjunior/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-07T13:16:05Z","updated_at":"2015-05-22T21:58:18Z","closed_at":null,"body":"Implementar uma função que retorna a quantidade de elementos existentes na pilha. Essa função deve possuir complexidade de tempo constante."},"comment":{"url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/comments/104785110","html_url":"https://github.com/bcc-ufg-ed1/PilhaEnc/issues/2#issuecomment-104785110","issue_url":"https://api.github.com/repos/bcc-ufg-ed1/PilhaEnc/issues/2","id":104785110,"user":{"login":"MarceloGouveia77","id":11440712,"avatar_url":"https://avatars.githubusercontent.com/u/11440712?v=3","gravatar_id":"","url":"https://api.github.com/users/MarceloGouveia77","html_url":"https://github.com/MarceloGouveia77","followers_url":"https://api.github.com/users/MarceloGouveia77/followers","following_url":"https://api.github.com/users/MarceloGouveia77/following{/other_user}","gists_url":"https://api.github.com/users/MarceloGouveia77/gists{/gist_id}","starred_url":"https://api.github.com/users/MarceloGouveia77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarceloGouveia77/subscriptions","organizations_url":"https://api.github.com/users/MarceloGouveia77/orgs","repos_url":"https://api.github.com/users/MarceloGouveia77/repos","events_url":"https://api.github.com/users/MarceloGouveia77/events{/privacy}","received_events_url":"https://api.github.com/users/MarceloGouveia77/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T21:58:17Z","updated_at":"2015-05-22T21:58:17Z","body":"Eu fiz de um jeito que acho que é constante, pois sempre quando empilhar ou desempilhar vai gastar 1 instrução a mais, independente de quantos elementos tiver, tentei acessar direto a posição do topo, mas não consegui, então fiz assim.\r\n\r\ntypedef struct {\r\n  No* topo;\r\n  int qtde; // Contador\r\n} PilhaEnc;\r\n\r\nno criarPilha iniciei o contador com 0\r\npilha->qtde = 0;\r\n\r\nna função empilhar add\r\npilha->qtde++;\r\n\r\ndesempilhar;\r\npilha->qtde--;\r\n\r\nint obterQntde(PilhaEnc* pilha, int *item){\r\n    if (pilha == NULL)\r\n        return ESTRUTURA_NAO_INICIALIZADA;\r\n        *item = pilha->qtde;\r\n    return OK;\r\n    }\r\n\r\nEu pensei em verificar se a pilha estava vazia, mas se estiver o contador já está com 0 elementos mesmo, ou deve haver a verificação mesmo assim? Porque a função é pra saber a quantidade de elementos, que no caso seria 0."}}