在排序链表时存储节点的变量(Variables to store node while sorting linked list)
我是一个遥远的学习学生,这次我会问社区'去哪里'。 该程序使用链表生成操作。 我理解有关节点的三个指针和两个要比较的候选者的想法。 与此同时,我没有意识到节点中临时存储信息的想法。 我应该声明节点的结构大小还是使用单独声明的变量?
提前谢谢了!
/* Define libraries to be included */ #include <stdio.h>/*standard input & out library*/ #include <malloc.h>/*allocate memory block*/ #include <string.h>/*defines memory functions to manipulate strings and arrays*/ #include <ctype.h>/*classifies and transform characters*/ #include <iomanip> using namespace std; /*----------------------------------------------------------------------*/ /* define structure there is no difference btw struct & class*/ typedef struct client { int number; /*unique account number*/ int balance;/*balance*/ char lastName[20]; /*contains family name*/ char firstName [20];/*contains name*/ char phone[20]; /*contains phone number 10 digits*/ char email[20]; struct client *prev;/* pointer is used to navigate through list of structures*/ struct client *next; /*next is used to navigate through structures.*/ } Client; Client *firstc,*currentc,*newc; /*pointers*/ /* 'firstc' is used to point to first record in list 'currentc' points to current record in list 'newc' contains address of new structure/node */ /*-------------------------------------------*/ voidSort() { /*temporary pointer to head of list*/ struct client *temphead; /*variables */ /* stumbling point: I suppose it's not correct*/ int tempnumber; /*unique account number*/ int tempbalance;/*balance*/ char templastName[20]; /*contains family name*/ char tempfirstName [20];/*contains name*/ char tempphone[20]; /*contains phone number 10 digits*/ char tempemail[20]; /*variable to count iterations */ int counter; if (firstc!==NULL) /*switch to head of list*/ struct client *temphead = firstc; while(temphead) { /* */ temphead = temphead->next; counter++; } temphead = firstc; for (int j = 0; j<coiunter; j++) while(temphead->next) { if(temphead->balance > temphead->next->balance) { tempbalance = temphead->balance; // temphead->balance = temphead->next->balance; // temphead->next->balance = tempbalance;// tempnumber = temphead->number; temphead->number = temphead->next->number; temphead->next->number = tempnumber; templastName = temphead->lastName //....................... } else temphead = temphead->next; } temphead = firstc; }
I'm a distant learning student and this time I would ask community 'where to go'. This program produce operations with linked list. I understand the idea about three pointers to nodes and two candidates to compare. At the same time I didn't catch the idea about temporary storage of information in the node. Should I declare structure size of node or use individually declared variables?
Many thanks in advance!
/* Define libraries to be included */ #include <stdio.h>/*standard input & out library*/ #include <malloc.h>/*allocate memory block*/ #include <string.h>/*defines memory functions to manipulate strings and arrays*/ #include <ctype.h>/*classifies and transform characters*/ #include <iomanip> using namespace std; /*----------------------------------------------------------------------*/ /* define structure there is no difference btw struct & class*/ typedef struct client { int number; /*unique account number*/ int balance;/*balance*/ char lastName[20]; /*contains family name*/ char firstName [20];/*contains name*/ char phone[20]; /*contains phone number 10 digits*/ char email[20]; struct client *prev;/* pointer is used to navigate through list of structures*/ struct client *next; /*next is used to navigate through structures.*/ } Client; Client *firstc,*currentc,*newc; /*pointers*/ /* 'firstc' is used to point to first record in list 'currentc' points to current record in list 'newc' contains address of new structure/node */ /*-------------------------------------------*/ voidSort() { /*temporary pointer to head of list*/ struct client *temphead; /*variables */ /* stumbling point: I suppose it's not correct*/ int tempnumber; /*unique account number*/ int tempbalance;/*balance*/ char templastName[20]; /*contains family name*/ char tempfirstName [20];/*contains name*/ char tempphone[20]; /*contains phone number 10 digits*/ char tempemail[20]; /*variable to count iterations */ int counter; if (firstc!==NULL) /*switch to head of list*/ struct client *temphead = firstc; while(temphead) { /* */ temphead = temphead->next; counter++; } temphead = firstc; for (int j = 0; j<coiunter; j++) while(temphead->next) { if(temphead->balance > temphead->next->balance) { tempbalance = temphead->balance; // temphead->balance = temphead->next->balance; // temphead->next->balance = tempbalance;// tempnumber = temphead->number; temphead->number = temphead->next->number; temphead->next->number = tempnumber; templastName = temphead->lastName //....................... } else temphead = temphead->next; } temphead = firstc; }
原文:https://stackoverflow.com/questions/16622228
最满意答案
您不能修改常量值(使用
const
修饰符标记的变量)。你有两个选择:
1)从场中删除
const
2)使用格式化在常量字符串中的占位符中插入值:
const string url = "http://smsmobile24.com/components/com_spc/smsapi.php?username=C***er&password=fath****am&sender=Cmanager&recipient={0}&message={1}"; var to = smsRecipientBox.Text; var msg = smsMsgBox.Text; string result = string.Format(url, to, msg);
You can't modify a constant value (variable that is marked with
const
modifier).You have two options here:
1) you remove the
const
from the field2) use formatting to insert values in placeholders in the constant string:
const string url = "http://smsmobile24.com/components/com_spc/smsapi.php?username=C***er&password=fath****am&sender=Cmanager&recipient={0}&message={1}"; var to = smsRecipientBox.Text; var msg = smsMsgBox.Text; string result = string.Format(url, to, msg);
相关问答
更多-
如何使用Twilio API跟踪对多个收件人的SMS响应?(How track responses for an SMS to multiple recipients with the Twilio API?)[2022-04-07]
**免责声明:Twilio福音传教士** 奇拉格: 所以听起来你有两个要求: 使用Twilio将出站文本消息发送给不同的收件人 捕获用户对该消息的回复 对于第一个要求,您可以先访问Twilio.com并注册新帐户。 它是免费的,我们会为您提供一个Twilio电话号码,您可以使用它来开始构建您的应用程序。 一旦拥有Twilio电话号码,就可以使用REST API开始发送来自该Twilio电话号码的出站短信。 我们有一个快速入门,向您展示如何执行此操作: http://www.twilio.com/docs/q ... -
那么我找到了一些解决方案,将用户重定向到各自的市场。 解决方案1 使用第三方工具,您可以通过短信发送单个链接,当用户点击该链接时,他们将重定向到市场。 下面是一些链接,可帮助您获取移动应用程序的单一链接。 一个链接 分支指标 还有很多 解决方案2 制作一个网页,您必须检查用户的设备和条件以将用户重定向到应用商店。 通过短信发送网页链接。 希望这会对一些人有所帮助。 Well I found some solution for redirecting users to there respective mar ...
-
SMS API建议[关闭](SMS API Suggestions [closed])[2023-07-20]
如果您正在寻找短信服务提供商? 你可以试试Clickatell 如果您正在考虑创建一个短信api,请查看Twitter API If you looking for a sms service provider? You could try Clickatell If you looking at creating a sms api, look at the Twitter API -
配置SMS API(Configuring SMS API)[2022-04-20]
您不能修改常量值(使用const修饰符标记的变量)。 你有两个选择: 1)从场中删除const 2)使用格式化在常量字符串中的占位符中插入值: const string url = "http://smsmobile24.com/components/com_spc/smsapi.php?username=C***er&password=fath****am&sender=Cmanager&recipient={0}&message={1}"; var to = smsRecipientBox.Text; ... -
WSO2IS配置SMS OTP(WSO2IS Configuring SMS OTP)[2022-01-22]
如果您在没有代理的情况下从网络外部连接时遇到问题,则可以在服务器启动期间使用以下jvm参数来提供代理配置。 例如: sh wso2server.sh -Dhttp.proxyHost=10.0.0.100 -Dhttp.proxyPort=8000 -Dhttp.nonProxyHosts="localhost|127.0.0.1|10.*.*.*" If you are having issues with connecting outside from your network without a p ... -
你忘了把例程放在括号中的“else”的情况下。 它应该是这样的: else { $this->strMessage=urlencode( $this->strMessage ); try { //Smpp http Url to send sms. $live_url = "http://".$this->host . ":" . $this->port."/bulksms/bulksms?username = ".$this->strUserNa ...
-
请看http://fortumo.com/api 似乎有你需要的功能:) Look at http://fortumo.com/api Seems to has the features you need:)
-
尝试添加以下依赖项: compile "com.google.android.gms:play-services-auth-api-phone:$playServicesVersion" Try adding the following dependency: implementation "com.google.android.gms:play-services-auth-api-phone:$playServicesVersion" replace $playServicesVersion with ...
-
它已被弃用,因为它是Legacy REST API的一部分,虽然它仍然可用,但正逐步淘汰支持Graph API(在某种程度上,FQL)。 我怀疑该权限仍然存在,以便开发人员有时间更新仍使用REST API的应用程序。 It has been deprecated, insofar as it is part of the Legacy REST API, which while still functional, is being phased out in favour of the Graph API ...
-
您必须打开到端口444的TCP套接字。如何做到这取决于您使用的语言,例如:PHP中的fsockopen ,Python中的套接字模块或.net中的system.net.sockets.socket 。 然后继续从响应中发送行,每行以换行符结束( \n )。 如果您愿意,您可以使用协议,而无需使用Windows中的Telnet或Linux / Unix中的netcat对客户端进行编程。 只需使用server / port作为参数运行程序,具体取决于您使用的冒号(:)分隔,如原始帖子或空格。 You'll ha ...