满楼水平吧 关注:27,809贴子:3,947,626

回复:C语言求教~~~

只看楼主收藏回复

会C语言,你再学JAVA就很轻松了!


来自手机贴吧18楼2011-09-25 07:49
回复
    不教


    来自手机贴吧19楼2011-09-25 07:56
    回复
      2026-04-15 09:12:34
      广告
      不感兴趣
      开通SVIP免广告
      不太理想


      IP属地:安徽来自手机贴吧20楼2011-09-25 08:07
      回复
        做这个就不需要和数据库连接了...直接放文件里就好...
        C 连接数据库可以用 ADO ...
        Java 用的是 ODBC 吧...猜错了你就原谅我...Java 正在学...


        21楼2011-09-25 08:21
        回复



          22楼2011-09-25 09:58
          回复
            用结构体还是类解决?


            IP属地:上海24楼2011-09-25 10:59
            回复
              JAVA用的是JDBC,ODBC貌似是.net的。没事我JAVA也是个菜鸡


              IP属地:吉林25楼2011-09-25 11:04
              回复
                把一种语言学通。其他的上手就很快了。


                IP属地:吉林26楼2011-09-25 11:05
                回复
                  2026-04-15 09:06:34
                  广告
                  不感兴趣
                  开通SVIP免广告



                  27楼2011-09-25 11:08
                  回复
                    结构体


                    28楼2011-09-25 11:08
                    回复
                      恩。。c不用类的。。我后来才想起来。。我以前用c++写过这个。。帮不了你了


                      IP属地:上海29楼2011-09-25 11:12
                      回复



                        30楼2011-09-25 11:16
                        回复
                          #include <stdio.h>
                          #include <stdlib.h>
                          #include <ctype.h>
                          #include <conio.h>
                          #include <string.h>
                          //头文件**************************************************************************
                          typedef struct StudNode
                          {
                          char name[30];
                          int number;
                          int age;
                          char sex;
                          double score;
                          char class_[30];
                          struct StudNode *next;
                          }node;
                          node *head,*thisN,*newN;
                          //声明函数*****************************************************************
                          void choice();
                          void insert_information();
                          void delete_information();
                          void modify_information();
                          void search_information();
                          void manage();
                          //menu**********************************************************************************
                          void Menu()
                          {
                          printf("\n***************************************************");
                          printf("\n* Student Manage System *");
                          printf("\n* *");
                          printf("\n* 1.insert statistic. *");
                          printf("\n* *");
                          printf("\n* 2.Delete statistic. *");
                          printf("\n* *");
                          printf("\n* 3.Search statistic. *");
                          printf("\n* *");
                          printf("\n* 4.modify statistic. *");
                          printf("\n* *");
                          printf("\n* 5.manager. *");
                          printf("\n* *");
                          printf("\n* 0.exit *");
                          printf("\n***************************************************");
                          }
                          //输入选择********************************************************************************
                          void choice()
                          {
                          char a;
                          printf("\nenter your choice:");
                          scanf("%c",&a);
                          getchar();
                          switch(a)
                          {
                          case '1':insert_information();break;
                          case '2':delete_information();break;
                          case '3':search_information();break;
                          case '4':modify_information();break;
                          case '5':manage();break;
                          case '0':exit(0);
                          default:printf("\n请不要乱输.再来一遍\n");break;
                          }
                          }
                          // 新建资料*****************************************************************
                          void insert_information()
                          {
                          system("cls"); //清屏
                          extern node *head,*thisN;
                          thisN = ( node *) malloc (sizeof(node)); //申请空间
                          thisN->next = head;
                          printf("\nenter name:");
                          gets(thisN->name);
                          printf("\nenter number:");
                          scanf("%d",&thisN->number);
                          printf("\nenter age:");
                          scanf("%d",&thisN->age);
                          getchar();
                          printf("\nenter sex(M=male/F=female):");
                          scanf("%c",&thisN->sex);
                          printf("\nenter score:");
                          scanf("%lf",&thisN->score);
                          getchar();
                          printf("\nenter class:");
                          


                          31楼2011-09-25 11:24
                          回复
                            gets(thisN->class_);
                            head = thisN;
                            return;
                            }
                            //删除数据*********************************
                            void delete_information()
                            {
                            int choose;
                            int StuNum;
                            char name[30],class_[30];
                            node *p1,*p2;
                            system("cls");//清屏
                            //空的
                            if ( head == NULL)
                            {
                            printf("\n空的删什么啊?\n");
                            return ;
                            }
                            //不是空的
                            //选择删除方式
                            printf("\nplese choose the way you want to delete:\nchoose 1 to delete by student number.\nchoose 2 to delete by student name\nchoose 3 to delete a class\n");
                            scanf("%d",&choose);
                            getchar();
                            //清屏
                            system("cls");
                            switch(choose)
                            {
                            case 1:
                            {
                            printf("\nplese input the number of the student:");
                            scanf("%d",&StuNum);
                            p1 = head;
                            while( StuNum != p1->number && p1->next != NULL)
                            {
                            p2 = p1; //临时保留
                            p1 = p1->next;
                            }
                            //找到出来
                            if( StuNum == p1->number)
                            {
                            if( p1 == head)
                            {
                            head = p1->next;
                            }
                            else
                            {
                            p2->next = p1->next;
                            }
                            free(p1);
                            printf("\n删了删了\n");
                            }
                            else
                            printf("\n找不到啊,大哥\n");
                            }break;
                            case 2:
                            {
                            printf("please input the name of the student:");
                            gets(name);
                            p1 = head;
                            while(strcmp(name,p1->name) != 0 && p1->next != NULL)
                            {
                            p2 = p1;
                            p1 = p1->next;
                            }
                            if(strcmp(name,p1->name) == 0)
                            {
                            if(p1 == head)
                            {
                            head = p1->next;
                            }
                            else
                            {
                            p2->next = p1->next;
                            }
                            free(p1);
                            printf("\n删掉了噢\n");
                            }
                            else
                            {
                            printf("\n找不到o\n");
                            }
                            }
                            break;
                            case 3:
                            {
                            printf("\nplease input the class you want to delete:");
                            gets(class_);
                            int flag;
                            do
                            {
                            flag = 0;
                            p1 = head;
                            while(strcmp(class_,p1->class_) != 0 && p1->next != NULL)
                            {
                            p2 = p1;
                            p1 = p1->next;
                            }
                            if(p1->next == NULL){printf("\n此班已经消除\n");flag = 1;}
                            if(strcmp(class_,p1->class_) == 0)
                            {
                            if(p1 == head)
                            {
                            head = p1->next;
                            }
                            else
                            {
                            p2->next = p1->next;
                            }
                            free(p1);
                            }
                            }while(flag == 0);
                            }
                            break;
                            }
                            return;
                            }
                            //查找数据***********************************************
                            void search_information()
                            {
                            extern node *head;
                            node *p1;
                            int Stunum;
                            system("cls");//清屏
                            //空
                            if( head == NULL)
                            {
                            printf("\n什么都没有查什么\n");
                            return;
                            }
                            //非空
                            printf("\n请输入你要查找的学号:");
                            scanf("%d",&Stunum);
                            getchar();
                            p1 = head;
                            while(Stunum != p1->number && p1->next != NULL)
                            {
                            p1 = p1->next;
                            }
                            //找到跳出循环
                            if( Stunum == p1->number)
                            {
                            printf("\nname:%s",p1->name);
                            printf("\nage:%d",p1->age); //输出
                            printf("\nclass:%s",p1->class_);
                            printf("\nnumber:%d",p1->number);
                            printf("\nsex:%c",p1->sex);
                            printf("\nscore:%f",p1->score);
                            }
                            else
                            {
                            printf("\n找不到啊\n");
                            return;
                            }
                            }
                            //修改数据**************************************************************
                            void modify_information()
                            {
                            extern node *head;
                            int studnum;
                            node *p1;
                            system("cls");//清屏
                            //empty
                            if( head == NULL)
                            {
                            printf("\n东西都没有你怎么改?\n");
                            return;
                            }
                            //no empty
                            p1 = head ;
                            printf("\n请输入你想查找的学号");
                            scanf("%d",&studnum);
                            getchar();
                            while( studnum != p1->number && p1->next != NULL)
                            {
                            p1 = p1->next;
                            }
                            //找到了出来
                            if( studnum == p1->number)
                            {
                            printf("\nenter name:");
                            gets(p1->name);
                            getchar();
                            printf("\nenter number:");
                            scanf("%d",&p1->number);
                            printf("\nenter age:");
                            scanf("%d",&p1->age);
                            printf("\nenter sex:");
                            scanf("%c",&p1->sex);
                            printf("\nenter score:");
                            scanf("%lf",&p1->score);
                            printf("\nenter clase:");
                            gets(p1->class_);
                            }
                            else
                            {
                            printf("\n真找不到。\n");
                            return;
                            }
                            }
                            //管理员权限
                            void manage()
                            {
                            printf("\n敬请期待。。。\n");
                            }
                            //主函数
                            int main()
                            {
                            extern node *head = NULL;
                            do
                            {
                            Menu();
                            choice();
                            printf("press anykey to continue\n");
                            getch();
                            getchar();
                            system("cls");
                            }while(1);
                            return 0;
                            }
                            坑爹版


                            32楼2011-09-25 11:24
                            回复
                              2026-04-15 09:00:34
                              广告
                              不感兴趣
                              开通SVIP免广告
                              表示压力很大...


                              33楼2011-09-25 11:25
                              回复