求大佬解答

展开阅读全文

大佬解答!!!

08-31

刚做了一道华为的测试题,不知道为啥,提交上去说我通过率只有20%,求解!!!rnrn[size=18px][b]题目:[/b][/size]rn给定一个整数,给出消除重复数字以后最大的整数rnrn输入描述:rnrn正整数,注意考虑长整数rnrn输出描述rnrn消除重复数字后的最大整数rnrn示例1rnrn输入rnrn423234rnrn输出rnrn432rnrn[size=18px][b]疑问:[/b][/size]rn1、题目中说到:注意考虑长整数是什么意思?rn2、请大佬们指出我的代码问题出来哪里,为什么只有20%通过率,哪些范围的数字通不过?rnrn附上我自己的代码,不明白为什么通过率只有20%:rn#include rn#include rnrnint num[100];rnrnvoid sort(int a[], int n) rnrn int i,j,k,t;rn for(i = 0; i < n - 1; ++i) rn rn k = i;rn for(j = i + 1; j < n; ++j) rn rn if(a[k] < a[j])rn k = j;rn rn if(i != k) rn rn t = a[i];rn a[i] = a[k];rn a[k] = t;rn rn rnrnrnint xiaochu(int a[], int n) rnrn int i,j,k;rn for(i = 0; i < n - 1; ++i) rn rn for(j = i + 1; j < n; ++j) rn rn if(a[i] == a[j])rn rn for(k = j; k < n - 1; ++k)rn rn a[k] = a[k + 1];rn rn --n;rn --j;rn rn rn rn return n;rnrnrnint main(void)rnrn long a = 423234;rn int i = 0;rnrn while(a)rn rn num[i] = a % 10;rn a = a / 10;rn i++;rn rnrn sort(num, i);rn int count = xiaochu(num, i);rnrn int temp = 0;rnrn for(int j = 0; j < count; j++)rn temp = temp * 10 + num[j];rnrn printf("%d\n", temp);rn //system("pause");rnrn return 0;rnrnrn这段代码我在考试的网页上点击自测,但是网上给出的答案是:rn[img=https://img-bbs.csdn.net/upload/201808/31/1535696754_819035.png][/img]rn但是自己在VS2010中编译计算后的结果是:rn[img=https://img-bbs.csdn.net/upload/201808/31/1535696864_511655.jpg][/img] 论坛

小白大佬解答python3

03-28

小白用的python3学习,应该是一个很简单的问题,但是自己搞了一天没搞定,就是这个script让unicode,然后网上找了一大堆办法,把它decode了,又报错说“utf-8 codec cant decode byte 0xb4...”,然后又decode('gbk'),也是“gbk codec cant decode byte…”。这个script明明是byte编码啊,为什么解码就不行了啊。实在找不到办法到这儿来求助各位大佬了。求不要让小白从入门到放弃啊[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif][/img][img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif][/img][img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif][/img][img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774088_306505.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774088_743672.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774089_656066.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774090_166086.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774087_981974.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774091_507633.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774101_792468.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774102_645963.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774103_398201.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774106_678246.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774104_614216.jpg][/img][img=https://img-bbs.csdn.net/upload/201903/28/1553774107_872860.jpg][/img] 论坛

【数据结构】指针和链表问题,大佬解答

11-27

![图片说明](https://img-ask.csdn.net/upload/201811/27/1543318209_622568.jpg)rn rn rn问题rn![图片说明](https://img-ask.csdn.net/upload/201811/27/1543318307_185667.jpg)rn```rn #include rn#include rn rn#define MAXSIZE 20rn rntypedef int ElemType; rntypedef structrnrn ElemType data;rn struct Node *next;rnNode,*LinkList;rn rnint main()rnrn //建立单链表rn LinkList LA;rn LA=(LinkList)malloc(sizeof(Node));rn LA->next=NULL;rn Node *r,*s;rn int c;rn r=LA;rn int flag=1,count=0; rn while(flag)rn rn printf("Please input new node to the LinkList,node must be intatger,input q to quit:\n");rn scanf("%d",&c);rn if(c!='q')rn rn s=(Node*)malloc(sizeof(Node));rn s->data=c;rn r->next=s;rn r=s;rn count++;rn rn elsern rn flag=0;rn r->next=NULL;rn rn rn Deal(&LA,count);rn rn //打印新生成的表rn printf("New LinkList is:\n");rn r=LA->next;rn while(r->next!=NULL)rn rn printf("%5d",r->data);rn rn return 0;rnrn rnint Deal(LinkList *LA,int n)//n为单链表长度,n为偶数 rnrn LinkList LB,LC;rn LB=(LinkList)malloc(sizeof(Node));//建立头结点rn LB->next=NULL;//建立空的单链表LBrn LC=(LinkList)malloc(sizeof(Node));//建立头结点rn LC->next=NULL;//建立空的单链表LCrn Node *p,*q,*r,*s; rn int i;rn p=LA->next->next;//令指针p指向序号为偶数的元素 rn q=LA->next;//令指针q指向序号为奇数的元素 rn r=LB;//令指针r指向LB rn s=LC;//令指针s指向LC rn rn rn //插入LB的第一个元素 rn LB->next=p;rn q->next=p->next;rn p=(p->next)->next;rn while(p->next!=NULL&&q->next!=NULL)rn rn //先插表LB rn //尾插法 (正序) rn s->next=q;rn LA=q->next;rn q=q->next->next;rn s=s->next; rn rn //头插法(逆序) rn p->next=LB->next;rn LB->next=p; rn p=p->next->next;rn rn rn //合并LB/LC两表rn if(p->next==NULL)rn rn p->next=LC->next;rn free(LC);rn rn return 0;rn rn rnrnrn``` 问答

日志猫的报错信息,大佬解答

08-11

[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/17.gif][/img]08-11 08:43:42.004: W/System.err(818): android.os.NetworkOnMainThreadExceptionrn08-11 08:43:42.004: W/System.err(818): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)rn08-11 08:43:42.004: W/System.err(818): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)rn08-11 08:43:42.004: W/System.err(818): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)rn08-11 08:43:42.014: W/System.err(818): at java.net.InetAddress.getAllByName(InetAddress.java:214)rn08-11 08:43:42.014: W/System.err(818): at libcore.net.http.HttpConnection.(HttpConnection.java:70)rn08-11 08:43:42.014: W/System.err(818): at libcore.net.http.HttpConnection.(HttpConnection.java:50)rn08-11 08:43:42.014: W/System.err(818): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)rn08-11 08:43:42.014: W/System.err(818): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)rn08-11 08:43:42.024: W/System.err(818): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)rn08-11 08:43:42.024: W/System.err(818): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)rn08-11 08:43:42.024: W/System.err(818): at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)rn08-11 08:43:42.034: W/System.err(818): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)rn08-11 08:43:42.034: W/System.err(818): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)rn08-11 08:43:42.034: W/System.err(818): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:282)rn08-11 08:43:42.034: W/System.err(818): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)rn08-11 08:43:42.034: W/System.err(818): at com.example.object_one.MainActivity.click(MainActivity.java:56)rn08-11 08:43:42.044: W/System.err(818): at java.lang.reflect.Method.invokeNative(Native Method)rn08-11 08:43:42.044: W/System.err(818): at java.lang.reflect.Method.invoke(Method.java:511)rn08-11 08:43:42.054: W/System.err(818): at android.view.View$1.onClick(View.java:3594)rn08-11 08:43:42.054: W/System.err(818): at android.view.View.performClick(View.java:4204)rn08-11 08:43:42.054: W/System.err(818): at android.view.View$PerformClick.run(View.java:17355)rn08-11 08:43:42.054: W/System.err(818): at android.os.Handler.handleCallback(Handler.java:725)rn08-11 08:43:42.064: W/System.err(818): at android.os.Handler.dispatchMessage(Handler.java:92)rn08-11 08:43:42.064: W/System.err(818): at android.os.Looper.loop(Looper.java:137)rn08-11 08:43:42.075: W/System.err(818): at android.app.ActivityThread.main(ActivityThread.java:5041)rn08-11 08:43:42.075: W/System.err(818): at java.lang.reflect.Method.invokeNative(Native Method)rn08-11 08:43:42.075: W/System.err(818): at java.lang.reflect.Method.invoke(Method.java:511)rn08-11 08:43:42.084: W/System.err(818): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)rn08-11 08:43:42.084: W/System.err(818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)rn08-11 08:43:42.084: W/System.err(818): at dalvik.system.NativeStart.main(Native Method)rn 论坛

一道c语言编程题,大佬解答

06-17

因为我实在是太菜了[face]monkey:50.gif[/face]希望不要被老师看到8n咱也没有积分…能给的都给了…n嘤嘤嘤大佬帮帮忙吧n题目描述:n给定一场ACM比赛的题目数量和提交列表,请你打印输出最终榜单。榜单的格式见输出和样例。n根据比赛规则,榜单有以下要求:nn每道题的通过罚时按照分钟计算。每次未通过提交增加20分钟罚时,输入数据保证每个队伍罚时均小于10000分钟。到比赛结束都没有通过的题目不计入该队伍的罚时。n每队通过后的题目在榜单的题目栏中用“+”号显示。如果仅提交一次就通过了,则显示“+”。否则显示“+k”,k 为这个队伍对于这道题通过之前的总提交次数。输入数据保证 k 不大于 9。n每队提交但是未通过的题目在榜单的题目栏中用“-”号显示。如果仅提交一次,则显示“-”。否则显示“-k”,k 为这个队伍对于这道题的总提交次数。输入数据保证 k 不大于9。n每队没有提交的题目需要在榜单的该队的题目栏留空。n题目提交状态为“Compile Error”的提交不计入榜单。n对于某个队伍,在通过某个题目后再次提交该题目,则通过后的提交不计入榜单。n如果某个队伍没有提交,或者所有的提交均不计入榜单。则榜单上不显示该队伍。n题目提交状态为“Accepted”的提交表示本题正确通过,其它状态均表示未通过。n输入描述:nn第一行一个数字 n(n≤14),表示这场比赛有 n 道题目,题目的标号从 A开始。n接下来若干行,每行格式形如:时间 题号 结果 队名,表示一条提交记录,提交记录按提交时间顺序排列。n其中,时间形如HH:MM,输入数据保证时间一定小于05:00。n题号为单独的一个大写字母。n结果属于集合 Accepted, Wrong Answer, Time Limit Exceeded, Compile Error, Memory Limit Exceeded, Output Limit Exceeded, Runtime Error, Presentation Error 。n队名为一个含有空格、大写和小写字母的字符串,队名长度不超过 43。n输入以一行 “GAME OVER!” 结尾,表示比赛结束。n输出描述:nn输出的榜单有 n+4栏,每栏之间间隔 2个空格。nRank一栏的宽度为 4个字符,表示该队伍的排名。nWho一栏的宽度43个字符,表示该队伍的名字。nSolved一栏宽度为 6个字符,显示每个队伍通过题目的数量。nPenalty一栏宽度为 7个字符,按要求显示每队总用时(每题通过时间+有效的总罚时)。n接下来是题目栏,每个题目栏的宽度均为 3个字符,按要求显示“+”或“-”,表示每个队伍通过题目的情况。n每一栏的第一行为这一栏的名称,其中,Who需左对齐,其他栏需右对齐。n题目栏的名称为题目的标号。n接下来若干行,按顺序输出每个队伍的信息,每栏的信息需右对齐。n队伍按照通过题目数量排名,如果两队通过题目数量相等,总用时少的队伍排名靠前。n如果出现题数和罚时均相等的队伍,则按照队名的字典序排序,同时Rank一栏的值需相等。第一个与他们排名不相等的队伍的排名选择绝对排名,例如前五个队伍的排名分别为1、2、3、3、3,则第六个队伍的绝对排名为6。 论坛

小弟菜鸟初学者,大佬解答,急

12-04

期末写的snake项目,写到下面的时候发现显示不了了rnpackage com.snake;rnrnimport javax.swing.JFrame;rnrnpublic class SnakeJFrame extends JFrame rn public SnakeJFrame() rn initframe();rn SnakeJPanel sJPanel = new SnakeJPanel();rn rn this.add(sJPanel);rn rn public void initframe() rn this.setTitle("5");rn this.setSize(800,800);rn this.setLocationRelativeTo(null);rn this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn this.setVisible(true);rn rn public static void main(String[] args) rn new SnakeJFrame();rn rnrnrnrnrnrnrnrnrnpackage com.snake;rnrnimport java.awt.Color;rnimport java.awt.Graphics;rnimport java.awt.event.KeyEvent;rnimport java.awt.event.KeyListener;rnrnimport javax.swing.JPanel;rnrnpublic class SnakeJPanel extends JPanel implements KeyListenerrn rn Snake snake =new Snake();rn Food food = new Food();rn public SnakeJPanel() rn startGame();rn rnrn rn private void startGame() rn // TODO Auto-generated method stubrn new Thread()rn public void run() rn while(true)rn snake.snakeMove();rn try rn Thread.sleep(300);rn catch (InterruptedException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn repaint();rn rn ;rn .start();rn rn rnrnrn @Overridern protected void paintComponent(Graphics g) rn // TODO Auto-generated method stubrn super.paintComponent(g);rn System.out.println("显示");rn setBackground(Color.gray);rn g.setColor(Color.RED);rn g.drawRect(100, 100, 600, 600);rn g.setColor(Color.WHITE);rn g.fillRect(100, 100, 600, 600);rn if(snake!=null&&food!=null)rn snake.drawSnake(g);rn food.drawFood(g);rn rn rn rnrnrn @Overridern public void keyPressed(KeyEvent e) rn // TODO Auto-generated method stubrn System.out.println("拿了");rn rn rnrnrn @Overridern public void keyReleased(KeyEvent e) rn // TODO Auto-generated method stubrn rn rnrnrn @Overridern public void keyTyped(KeyEvent e) rn // TODO Auto-generated method stubrn rn rnrnrnrnrnrnpackage com.snake;rnrnimport java.awt.Color;rnimport java.awt.Graphics;rnimport java.awt.Point;rnimport java.util.LinkedList;rnrnpublic class Snake rn int snakex = 400, snakey = 400;rn LinkedList body = new LinkedList<>();rn final static int up = 1, down = -1, left = 2, right = -2, direction = -2;rnrn public Snake() rn initBody();rn rn rnrn public void snakeMove() rn System.out.println("蛇正在移动");rn int x = body.getFirst().x;rn int y = body.getFirst().y;rn switch (direction) rn case up:rn y--;rn body.addFirst(new Point(x, y));rn break;rn case down:rn y++;rn body.addFirst(new Point(x, y));rn break;rn case left:rn x--;rn body.addFirst(new Point(x, y));rn break;rn case right:rn x++;rn body.addFirst(new Point(x, y));rn break;rnrn rnrn rnrn public void initBody() rn for (int i = 0; i < 3; i++) rn body.add(new Point(snakex + i * 10, snakey));rn rn rnrn public void drawSnake(Graphics g) rn System.out.println("蛇正在绘制");rn g.setColor(Color.GREEN);rn for (int i = 0; i < body.size(); i++) rn g.fillRect(body.get(i).x, body.get(i).y, 10, 10);rn rn rnrnrnrnrnrnrnrnrnpackage com.snake;rnrnimport java.awt.Color;rnimport java.awt.Graphics;rnrnpublic class Food rn int Foodx = (int) (Math.random() * 600) + 100;rn int Foody = (int) (Math.random() * 600) + 100;rn rn public void drawFood(Graphics g) rn // TODO Auto-generated method stubrn System.out.println("食物正在绘制");rn g.setColor(Color.red);rn g.fillRect(Foodx, Foody, 10, 10);rn rnrnrn 论坛

有两个main函数,大佬解答一下。

06-27

#include n#includen#include n#include nint login() n n char secercode[6]; n int number = 3; n printf("\n\n\n"); n printf("\t\t**********欢迎使用管理系统**************"); n printf("\n\n"); n scanf("%s",secercode); n while (number>0) n n if (strcmp(secercode,"88888888")==0) n return EXIT_SUCCESS; //while语句里面的结束循环用break是不对的 n else n n number--; n if(number<=0)break; n printf("\t\t\t 还有%d次机会\n",number); n printf("\n\t\t\t请输入密码: "); n scanf("%s",secercode); n n n if(number>0) return 1; n else return 0; n nmainMenu() n n printf("密码正确 \n"); n return 0;n nmain() n n if (login() == 0)return 1; n do n n mainMenu(); n while(1); n nntypedef struct tagCustomernn char m_ID[18]; /*身份证号码*/n char m_name[10]; /*顾客姓名*/n int m_age; /*顾客年龄*/n char m_sex[6]; /*顾客性别*/n int num;nCustomer;/*顾客结构*/nntypedef struct tagRoomnn int m_num; /*房间号*/n int m_floor; /*楼层*/n int m_price; /*价格*/n int m_use; /*是否已入住*/nRoom;/*房间结构*/nint i,j=0,age,num,floor,price,use,n;nint reg =0;nCustomer cus[5];nRoom r[5];nint count=5;nchar ID[18],name[10],sex[6];nFILE *fproom;nFILE *fpcustomer;nnvoid Customer_Input()nn if(count<=5)n n printf("请输入身份证号(18位数字):");n scanf("%s",&cus[j].m_ID);n printf("请输入姓名(10位字符)");n scanf("%s",&cus[j].m_name);n printf("请输入年龄(数字型)");n scanf("%d",&cus[j].m_age);n printf("请输入性别(男或女):");n scanf("%s",&cus[j].m_sex);n n elsen n printf("\n 存储空间已满!");n n printf("\n\r顾客可以住在:");n printf("\n\r房间号 楼层 价格 是否空闲(1:空闲0:已使用)");n for(i=0;i0&&n<=6)n n switch(n)n n case 1:Customer_Input();break;n case 2:Customer_ListOut();break;/*查询顾客信息*/n case 3:Room_ListOut();break;/*查询空房间*/n case 4:PerCustomer_Search();break;/*预订房间*/n case 5:UnCustomer_Out();break;/*退订房间*/n case 6:Customer_Goaway(); /*保存退出*/n n n else n n printf("***********************************************************************\n");n printf("* *\n");n printf("* 输入错误! *\n");n printf("* 请退出! *\n");n printf("* *\n");n printf("***********************************************************************\n");n break;n n nn 问答

没有更多推荐了,返回首页