WEB开发网
开发学院软件开发C++ C的数据库编程(2) 阅读

C的数据库编程(2)

 2008-03-08 12:37:53 来源:WEB开发网   
核心提示:if (found_num != 0) PRintf("find %d\n",found_num);else printf("no record\n"); } elseprintf("out record\n"); break; case 7: print
 if (found_num != 0)
    PRintf("find %d\n",found_num);
 else
    printf("no record\n");
   }
   else
 printf("out record\n");
   break;
 case 7:
   printf("\n");
   printf("force:");
   scanf("%d",&find_force);
   if (head != nil) {
 c = head;
 l = c->next;
 found_num = 0;
 output_title();
 for (i = 1; i <= count; i++) {
    if (c->force == find_force) {
  output_it(c,i);
  found_num = found_num + 1;
  c = l;
  l = c->next;
    }
    else  {
  c = l;
  l = c->next;
    }   /*IF*/
 }   /*FOR*/
 if (found_num != 0)
    printf("find %d\n",found_num);
 else
    printf("no record\n");
   }
   else
 printf("out record\n");
   break;
 case 8:
   printf("\n");
   printf("smartness:");
   scanf("%d",&find_smartness);
   if (head != nil) {
 c = head;
 l = c->next;
         found_num = 0;
         output_title();
         for (i = 1; i <= count; i++) {
    if (c->smartness == find_smartness) {
  output_it(c,i);
             found_num = found_num + 1;
  c = l;
  l = c->next;
    }
    else  {
  c = l;
  l = c->next;
    }   /*IF*/
 }   /*FOR*/
 if (found_num != 0)
    printf("find %d\n",found_num);
 else
    printf("no record\n");
   }
       else
 printf("out record\n");
   break;
 default:
   printf("find error\n");
   break;
   }   /*CASE*/
} void sort_record (void)
{ int condition_code;
int i,
   j; int long_c,long_f;
strUCt node *c_bak,
   *l_bak;    condition_code = condition_select("sort condition:");
   switch (condition_code) {
 case 1:
   printf("record over\n");
   break;
 case 2:
   if ((head != nil) && (head->next != nil)) {
 c_bak = current;
 l_bak = last;   /*沉淀法排序*/
 for (i = count - 1; i >= 1; i--) {
    current = c_bak;
    last = l_bak;
    for (j = 1; j <= i; j++) {
  if (current->number < current->front->number)
    swap_it(¤t,&last,&c_bak,&l_bak);
             current = current->front;
  last = current->next;
           }
         }
         current = c_bak;
         last = l_bak;
   }
   printf("no over\n");
   break;
     case 3:
       if ((head != nil) && (head->next != nil)) {
         c_bak = current;
         l_bak = last;   /*沉淀法排序*/
         for (i = count - 1; i >= 1; i--) {
           current = c_bak;
           last = l_bak;
           for (j = 1; j <= i; j++) {
             if (strcmp(current->name,
  current->front->name) < 0)
               swap_it(¤t,&last,&c_bak,&l_bak);
             current = current->front;
  last = current->next;
           }
         }
         current = c_bak;
         last = l_bak;
       }
   printf("name over\n");
       break;
     case 4:
   if ((head != nil) && (head->next != nil)) {
         c_bak = current;
         l_bak = last;   /*沉淀法排序*/
         for (i = count - 1; i >= 1; i--) {
           current = c_bak;
  &nbs

Tags:数据库 编程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接