小编Tej*_*eja的帖子

在C中打印链接列表

我正在尝试使用C.打印链接列表.但是当我执行我的./a.out时,它会将我打印为空.有人可以帮我解决我做错的地方.谢谢.

#include<stdio.h>
#include<stdlib.h>

struct node
{
        int data;
        struct node *next;
};

int main()
{
        node *start,*temp;
        start = (node *)malloc(sizeof(node));
        temp = start;
        temp -> next = NULL;
        while(1)
        {
                int query;
                printf("1.Insert\n");
                printf("2.Print\n");
                printf("Enter your choice:\n");
                scanf("%d",&query);
                if(query==1)
                {
                        int data;
                        printf("Enter the element to be inserted.\n");
                        scanf("%d",&data);
                        while(start->next!=NULL)
                        {
                                start = start -> next;
                        }
                        start->next = (node *)malloc(sizeof(node));
                        start = start->next;
                        start->data = data;
                        start->next = NULL;
                }
                else if(query ==2)
                {
                        printf("The list is as …
Run Code Online (Sandbox Code Playgroud)

c linked-list

0
推荐指数
1
解决办法
2215
查看次数

Break语句不在循环内或在C中切换

我在我的C代码中收到此错误.我不知道我做错了什么.如果我评论此代码我的程序工作.这段代码在int main()中.

 if(argc!=2 && strcmp(argv[0],"selection-sort")==0 && strcmp(argv[1],"input.txt")==0 && strcmp(argv[2],"output.txt")==0)
        {
                printf("The command line arguments are correct.\n");
        }
        else
        {
                printf("The command line arguments are wrong.I am exiting.\n");
                break;
        }
Run Code Online (Sandbox Code Playgroud)

c if-statement break

0
推荐指数
1
解决办法
4万
查看次数

如何计算特定国家/地区的利润中位数

大家好,我是R的新手,我正在尝试计算数据框中某个特定国家/地区的中等利润.我尝试了下面一个,但它对我不起作用.

data("Forbes2000", package = "HSAUR")
median(Forbes2000[,"sales","country"="United States"])
Run Code Online (Sandbox Code Playgroud)

r median

0
推荐指数
1
解决办法
672
查看次数

分段故障没有明显原因发生

我没有明显的理由得到分段错误.我正在使用该strtok函数并将每一行拆分为多个标记并将它们存储在char指针中.我的数据如下:

输入:

200 -> 103 [weight=7];
200 -> 153 [weight=27];
200 -> 53 [weight=9];
200 -> 178 [weight=43];
55 -> 2 [weight=23];
55 -> 14 [weight=50];
55 -> 20 [weight=17];
55 -> 22 [weight=1];
55 -> 74 [weight=7];
55 -> 93 [weight=9];
55 -> 122 [weight=27];
65 -> 8 [weight=27];
65 -> 9 [weight=9];
Run Code Online (Sandbox Code Playgroud)

码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc,char **argv)
{
        char *ipfile,line[80];
        FILE *fp;
        char *field1,*field2,*field3,*field4,*field5,*field6,mystr[10];
        int row,column,weight;
        ipfile = (char *)argv[1]; …
Run Code Online (Sandbox Code Playgroud)

c segmentation-fault

0
推荐指数
1
解决办法
548
查看次数

使用模式从字符串中提取子字符串

我想从基于模式的长字符串中提取子字符串。想知道获得它的最佳方法是什么?

http://abcdef?menu=xyz&source=push&push_id=1212239617294503480&message_id=7658a0a6-9d31-4c3c-9aa0-9169f24e2fdc
Run Code Online (Sandbox Code Playgroud)

图案: 'menu'

子串寻找: 'xyz'

regex sql string regex-group presto

0
推荐指数
1
解决办法
2413
查看次数

=运算符抛出异常

我是一个非常新闻的Java程序员.我正在尝试使用compareTo函数对字符串数组进行排序.但是在我的代码中,'='运算符导致代码出现问题.有人可以帮我吗?谢谢

public class StringSort 
{
    static String arr[]= ("Now","My","There","When");
        public static void main(String[] args) 
    {

        for(int i=0;i<arr.length;i++)
        {
            for(int j=0;j<arr.length;j++)
            {
                if(arr[i].compareTo(arr[j])<0)
                {
                    String t=arr[j];
                    arr[j]=arr[i];
                    arr[i]=t;
                }
            }
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

java sorting

-1
推荐指数
1
解决办法
97
查看次数