Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <string.h>
  5.  
  6. typedef struct node{
  7. int info;
  8. char * val;
  9. struct node* next;
  10. }node;
  11.  
  12. int menu(){
  13. int opcao=10;
  14. printf("\nInserir tarefas na lista To Do\t\t\t\t (1)\n");
  15. printf("Mover tarefas de To do para Doing\t\t\t (2)\n");
  16. printf("Mover tarefas de Doing para To do\t\t\t (3)\n");
  17. printf("Mover tarefas de Done para To do\t\t\t (4)\n");
  18. printf("Mover tarefa para Done\t\t\t\t\t\t (5)\n");
  19. printf("Alterar utilizador de uma tarefa em Doing\t (6)\n");
  20. printf("Ver as tarefas atribuídas a um utilizador\t (7)\n");
  21. printf("Ver as tarefas por ordem de criação\t\t\t (8)\n");
  22. printf("Sair\t\t\t\t\t\t\t\t\t\t (0)\n\n");
  23. while(opcao>8 || opcao<0){
  24. printf("Escolha uma opção 0-8: ");
  25. scanf("%d",&opcao);
  26. }
  27. return opcao;
  28. }
  29.  
  30. node* criar(){
  31. node*aux = (node*) malloc (sizeof (node));
  32. assert(aux);
  33. aux -> next = NULL;
  34. return aux;
  35. }
  36.  
  37. void insere_inicio(node*h, char*palavra){
  38. node*aux = (node*) malloc(sizeof(node));
  39. aux -> val=palavra;
  40. aux -> next= h->next;
  41. h -> next=aux;
  42. }
  43.  
  44. void print_lista(node*h){
  45. for(h=h->next;h;h=h->next)
  46. printf("%s", h->val);
  47. }
  48.  
  49. void sortlist(node*h){
  50. node*aux = h;
  51. char*a;
  52. int trocas=0;
  53. do{
  54. trocas=0;
  55. h=aux->next;
  56. while(h->next!=NULL) {
  57. if (strcmp(h->val, h->next->val) > 0) {
  58. a = h->val;
  59. h->val = h->next->val;
  60. h->next->val = a;
  61. trocas++;
  62. }
  63. h = h->next;
  64. }
  65. }while(trocas>0);
  66. }
  67.  
  68. int main(){
  69. node*todo;
  70. todo=criar();
  71. char input[128];
  72. printf("\tBem-vindo ao Quadro Kanban\n");
  73. int a=menu();fgets(input,100,stdin);
  74. switch(a){
  75. case 1:
  76. printf("Tarefa a inserir: ");
  77. fgets(input,100,stdin);strtok(input,"\n");
  78. insere_inicio(todo,input);
  79. }
  80.  
  81. FILE *ftodo;
  82. ftodo = fopen("todo.txt", "w");
  83. fwrite(input,1,sizeof(input),ftodo);
  84. fclose(ftodo);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement