using namespace std; void grading();
/**********Program**********/
/********** End **********/
int main() {
cout<<\秒转化后为:\
cout< //忽略阅读开始 grading(); //忽略阅读结束 return 0; } //以下忽略阅读 void grading() { ifstream rf(\ ofstream wf(\ int n; for (int i =1; i<=10; i++){ rf>>n; wf< } rf.close(); wf.close(); } 答案:struct MyTime { }; MyTime myfun( int second) { } 第12题 (6.0分) 题号:550 /*------------------------------------------------ 【程序设计】 -------------------------------------------------- 题目:完成函数listSort的编写,该函数对单向链表进行 从小到大排序并返回。 -------------------------------------------------- 注意:仅在标有\和\的注释行之间补充填写 代码。请勿改动主函数main和其它任何已有内容。 ------------------------------------------------*/ #include MyTime mytime ; mytime.hh= second/3600; mytime.mm=( second-mytime.hh*3600)/60; mytime.ss= second-mytime.hh*3600-mytime.mm*60; return mytime; int hh; int mm; int ss; #include struct Node { int num; Node *next; }; Node * listSort(Node *head) { /*********Program*********/ /********* End *********/ } void deleteList(Node *head) { Node *tmp; while (head) { tmp = head->next; delete head; head = tmp; } } void printList(Node *head) { while(head) { cout< cout< Node * createList(int a[], int len) { Node *head = NULL; if(len<1) return head; for(int i=0;i Node *tmp = new Node; tmp->num = a[i]; tmp->next = head; head = tmp; } return head; } int main() { int s[8] = {2,6,4,2,7,9,5,12}; Node * head = createList(s,8); head = listSort(head); printList(head); //忽略阅读 grading(); //忽略阅读结束 deleteList(head); return 0; } //忽略阅读 void whiteFile(fstream &outfile, Node *head) { while(head) { outfile< outfile< void grading() { int a[200],i; fstream infile, outfile; infile.open (\ outfile.open(\ for (i=0;i<200;i++) infile>>a[i]; for (i=0;i<8;i++) { Node * head = createList(a+i*2,6+i); head = listSort(head); whiteFile(outfile, head); } infile.close(); outfile.close(); } //忽略阅读结束 答案: Node *tmp = head, *h = NULL; while (tmp) { head = tmp->next; Node *pre = NULL, *cur = h; while(cur && tmp->num > cur->num) { } if(pre == NULL) { } else tmp->next = h; h = tmp; pre = cur; cur = cur->next; } { } tmp = head; tmp->next = cur; pre->next = tmp; return h;