亡羊补牢未必算完

     终于有时间痛痛快快地玩LINUX,真爽!!!

     忽然我发现了一个很尴尬的现象:现在很多网页都是用ASP或.NET做的,这些网页在LINUX上别说执行有问题,有些显示都有问题!

     各位同道,垄断真的太可怕了。假若有一天我们发现离开某公司的产品就不行了,就象《笑傲江湖》中黑木崖上的那些小喽罗,没有东方不败定期给他们三尸脑神丹的解药就不能存活了,那将是多么恐怖!!!

    那么就让我们从现在开始行动吧,努力改变MS接近一统江湖局面。

    亡羊补牢未必算完。。。。。。

亡羊补牢-面试题

10-24

rnrn前几天我在轮坛上贴出了我去一家公司面试遇到的题,当然面试的结果是以我的失败告终。rn在我把我的代码贴出来后有许多DX给了我帮助和提示,按照这些我把我的程序修改了一下,请大家看看:rnrn题目:rn用户输入若干字符串,如果输入的是0000rn表示结尾,对用户输入的字符串排序并输出到屏幕。rnrn完整的代码:rnrn#include "stdafx.h"rnrnrn//------------------------------------rn//字符链表结构rn//------------------------------------rnstruct char_structrnrn char a;rn char_struct* next;rn;rnrn//------------------------------------rn//字符串链表结构rn//------------------------------------rnstruct str_structrnrn char* str;rn str_struct* next;rn;rnrn//------------------------------------------------------rn//获取一个字符串rn//------------------------------------------------------rnint GetStr(char_struct* p)rnrnrnchar_struct *q;rnrnint j = 0;rnrn while(1)rn rn q = (char_struct*)malloc(sizeof(struct char_struct));rnrnrn q->a = getchar();rn j++;rnrn p->next = q;rn p=q;rnrn if(q->a == '\n')rn break;rn rnrn p->next = NULL;rnrn return j;rnrnrnrn//------------------------------------------rn//排序rn//------------------------------------------rnvoid str_sort(bool temp,str_struct *str_head,str_struct *str_p,str_struct *str_p_front,str_struct *str_temp)rnrnrn// 为字符串排序所设的字符位置变量rnint test_sort = 0;rnrn if(temp == false)rn rn str_head->next = str_temp;rn str_temp->next = NULL;rn rn rn rn while(temp)rn rn rn while( rn (str_p->str[test_sort] != '\0') rn && (str_temp->str[test_sort] != '\0') rn && str_p->str[test_sort] == str_temp->str[test_sort] rn )rn rn test_sort++;rn rnrn if( str_p->str[test_sort] < str_temp->str[test_sort]) rn rn if(str_p->next != NULL)rn rn str_p_front = str_p;rn str_p = str_p->next;rn rn elsern rn rn str_p->next = str_temp;rn str_temp->next = NULL; rn temp = false;rn rn rn elsern rn str_p_front->next = str_temp; rn str_temp->next = str_p;rn temp = false;rn rn rn rnrnrnrn//------------------------------------------rn//输入字符串rn//------------------------------------------rnvoid InStr(str_struct *str_head)rnrnrnstr_struct *str_p, *str_p_front;rnrn str_p = (str_struct*)malloc(sizeof(struct str_struct));rnstr_p_front = (str_struct*)malloc(sizeof(struct str_struct)); rnrnstr_p->next = NULL;rnstr_p->str = NULL;rnrnstr_head->next = str_p;rnrn char_struct *temp_end;rnrntemp_end = (char_struct*)malloc(sizeof(struct char_struct));rnrnrn//为检测字符串所设的中间变量rnchar chr_test_end = 0;rnrn// 为跳出循环rnbool temp = false;rnint i = 0;rnint j = 0;rnstr_struct *str_temp;rnrnchar_struct* head, *p;rnrnwhile(1)rnrn head = p = (char_struct*)malloc(sizeof(struct char_struct)); rn str_p = str_head->next;rn str_p_front = str_head;rnrn printf("into please: ");rnrn p = head;rnrn head->a = getchar();rn head->next = NULL;rnrnrn if(head->a != '\n')rn rnrn j = GetStr(p);rnrnprintf("\n");rnrnrnstr_temp = (str_struct*)malloc(sizeof(struct str_struct));rnrnrn str_temp->str = (char*)malloc((j+1)*sizeof(char));rnrn memset(str_temp->str,'\0',(j+1));rnrnrntemp_end = head;rnrnrn for(int k=0;kstr[k] = head->a;rnrnrn head = head->next;rn rn rnrnstr_sort( temp, str_head,str_p,str_p_front,str_temp);rnrnrnrnj = 0;rn temp = true;rnrnrnrnwhile( (temp_end->a == '0') && (i < 5) )rnrn ++i;rn temp_end = temp_end->next;rnrnrnchr_test_end = temp_end->a;rnrnwhile(head != NULL)rnrn p = head;rn head = head->next;rn free(p);rnrnrnif( (chr_test_end =='\n')rn && (i==4) ) break; rnrni = 0;rnrn rn rnrnrnrnrnrn//----------------------------------------rn// mainrn//----------------------------------------rnint _tmain(int argc, _TCHAR* argv[])rn rnrnstr_struct *str_head, *str_temp;rnrnstr_head = (str_struct*)malloc(sizeof(struct str_struct));rnstr_temp = (str_struct*)malloc(sizeof(struct str_struct)); rnrn str_head->str = NULL;rnrn InStr(str_head);rnrnstr_head = str_head->next;rnstr_temp = str_head;rnrnrnwhile(str_head != NULL)rnrnrnprintf("\n");rnprintf("%s",str_head->str);rnprintf("\n");rnrn str_head = str_head->next;rnrnrnwhile(str_temp != NULL)rnrn str_head = str_temp;rn str_temp = str_temp->next;rn free(str_head->str);rn free(str_head);rnrnrnprintf("\n");rnrn return 0;rnrnrn请各位对我的代码畅所欲言,批评的越尖锐我越高兴,谢谢先!rn

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

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭