{"action":"created","issue":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/27","labels_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/27/comments","events_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/27/events","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/27","id":117049709,"number":27,"title":"软件：期中考试问题总结","user":{"login":"ghostbody","id":8371330,"avatar_url":"https://avatars.githubusercontent.com/u/8371330?v=3","gravatar_id":"","url":"https://api.github.com/users/ghostbody","html_url":"https://github.com/ghostbody","followers_url":"https://api.github.com/users/ghostbody/followers","following_url":"https://api.github.com/users/ghostbody/following{/other_user}","gists_url":"https://api.github.com/users/ghostbody/gists{/gist_id}","starred_url":"https://api.github.com/users/ghostbody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghostbody/subscriptions","organizations_url":"https://api.github.com/users/ghostbody/orgs","repos_url":"https://api.github.com/users/ghostbody/repos","events_url":"https://api.github.com/users/ghostbody/events{/privacy}","received_events_url":"https://api.github.com/users/ghostbody/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/labels/%E8%BD%AF%E4%BB%B6%E7%8F%AD","name":"软件班","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":52,"created_at":"2015-11-16T04:33:33Z","updated_at":"2015-11-22T13:12:13Z","closed_at":null,"body":"# 软件学院15级教务1班程序设计(实验)期中考试参考答案\r\n\r\n## 1000\r\n```c\r\n#include <stdio.h>\r\n\r\nint main() {\r\n  int n;\r\n  int plus;\r\n  int min;\r\n  int flag = 1;\r\n\r\n  scanf(\"%d\", &n);\r\n\r\n  int i, j, k;\r\n  plus = n / 2;\r\n  min = 0;\r\n  \r\n  for(i = 0; i < n; i++) {    \r\n    for(j = 0; j < min; j++) {\r\n      printf(\"-\");\r\n    }\r\n    for(j = 0; j < plus; j++) {\r\n      printf(\"+\");\r\n    }\r\n    printf(\"+\");\r\n    for(j = 0; j < plus; j++) {\r\n      printf(\"+\");\r\n    }\r\n    for(j = 0; j < min; j++) {\r\n      printf(\"-\");\r\n    }\r\n    printf(\"\\n\");\r\n    if(flag) {\r\n      plus --;\r\n      min ++;\r\n    } else {\r\n      plus++;\r\n      min--;\r\n    }\r\n\r\n    if(plus <= 0) {\r\n      flag = 0;\r\n    }\r\n  }\r\n  \r\n  return 0;\r\n}\r\n\r\n```\r\n\r\n## 1001\r\n```c\r\n#include <stdio.h>\r\n\r\nconst int chair = 30;\r\nconst int trees = 10;\r\n\r\nint main() {\r\n  int i;\r\n  int height;\r\n  int apple[10];\r\n  int ans = 0;\r\n  \r\n  for(i = 0; i < trees; i++) {\r\n    scanf(\"%d\", &apple[i]);\r\n  }\r\n  scanf(\"%d\", &height);\r\n  for(i = 0; i < trees; i++) {\r\n    if(height + chair >= apple[i]) {\r\n      ans ++;\r\n    }\r\n  }\r\n\r\n  printf(\"%d\\n\", ans);\r\n  \r\n  return 0;\r\n}\r\n```\r\n## 1002\r\n```c\r\n#include <stdio.h>\r\n\r\nint main() {\r\n  int m,n;\r\n  int i;\r\n  unsigned long long ans;\r\n  scanf(\"%d\", &m);\r\n\r\n  while(m--) {\r\n    scanf(\"%d\", &n);\r\n    ans = 1;\r\n    for(i = 2; i <= n; i++) {\r\n      ans += i*i*i;\r\n    }\r\n    printf(\"%lld\\n\", ans);\r\n  }\r\n  \r\n  return 0;\r\n}\r\n\r\n```\r\n## 1003\r\n```c\r\n#include <stdio.h>\r\n\r\nint main() {\r\n  int n;\r\n  int array[101];\r\n  int i, j;\r\n  int ans;\r\n  \r\n  while(scanf(\"%d\", &n) && n) {\r\n    ans  = 0;\r\n    for(i = 0; i < n; i++) {\r\n      scanf(\"%d\", &array[i]);\r\n    }\r\n\r\n    for(i = 0; i < n; i++) {\r\n      for(j = 0; j < n; j++) {\r\n\tif(array[j] * 2 == array[i]) {\r\n\t  ans++;\r\n\t}\r\n      }\r\n    }\r\n    printf(\"%d\\n\", ans);\r\n  }\r\n\r\n}\r\n\r\n```\r\n## 1004\r\n```c\r\n#include<stdio.h>\r\n\r\nint main(){\r\n  int i,j,a[1000][1000];\r\n  int n;\r\n  while(scanf(\"%d\", &n) && n) {\r\n    for(i = 0; i < n; i++) {\r\n      for(j = 0; j < n; j++){\r\n\ta[i][0] = 1;\r\n\ta[i][i] = 1;\r\n      }\r\n    }\r\n    for(i = 2; i < n; i++) {\r\n      for(j = 1; j <= i-1; j++) {\r\n\ta[i][j] = a[i-1][j-1] + a[i-1][j];\r\n      }\r\n    }\r\n    for(i = 0; i < n; i++){\r\n      for(j = 0; j <= i; j++) {\r\n\tprintf(\"%d\\t\", a[i][j]);\r\n      }\r\n      printf(\"\\n\");\r\n    }\r\n  }\r\n  return 0;\r\n}\r\n\r\n```\r\n## 1005\r\n```c\r\n#include <stdio.h>\r\n\r\nint main() {\r\n  int start_hour;\r\n  int start_min;\r\n  int end_hour;\r\n  int end_min;\r\n\r\n  int sleep_hour;\r\n  int sleep_min;\r\n  \r\n  scanf(\"%d:%d\", &start_hour, &start_min);\r\n  scanf(\"%d:%d\", &end_hour, &end_min);\r\n\r\n  if((end_hour < start_hour) ||\r\n     ((end_hour == start_hour) && (start_min > end_min))) {\r\n    end_hour += 24;\r\n  }\r\n  \r\n  sleep_hour = end_hour - start_hour;\r\n  sleep_min = end_min - start_min;\r\n  \r\n  if(sleep_min < 0) {\r\n    sleep_min += 60;\r\n    sleep_hour--;\r\n  }\r\n\r\n  if(sleep_hour < 10){\r\n    printf(\"0\");\r\n  }\r\n  printf(\"%d:\", sleep_hour);\r\n\r\n  if(sleep_min < 10) {\r\n    printf(\"0\");\r\n  }\r\n  printf(\"%d\\n\", sleep_min);\r\n\r\n  return 0;\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/comments/158758847","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/27#issuecomment-158758847","issue_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/27","id":158758847,"user":{"login":"revnos","id":15195952,"avatar_url":"https://avatars.githubusercontent.com/u/15195952?v=3","gravatar_id":"","url":"https://api.github.com/users/revnos","html_url":"https://github.com/revnos","followers_url":"https://api.github.com/users/revnos/followers","following_url":"https://api.github.com/users/revnos/following{/other_user}","gists_url":"https://api.github.com/users/revnos/gists{/gist_id}","starred_url":"https://api.github.com/users/revnos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revnos/subscriptions","organizations_url":"https://api.github.com/users/revnos/orgs","repos_url":"https://api.github.com/users/revnos/repos","events_url":"https://api.github.com/users/revnos/events{/privacy}","received_events_url":"https://api.github.com/users/revnos/received_events","type":"User","site_admin":false},"created_at":"2015-11-22T13:12:13Z","updated_at":"2015-11-22T13:12:13Z","body":"第一题想了太久…到后面脑子直接乱掉。后来发现其实也没有太难……\r\n杨辉三角直接傻掉，看到AC的人太少我去做了最后一题，用%d:%d来做结果失败了发现只是自己的输出没有%02d...简直崩溃.还是很多知识点都没搞清用的时候就没用上\r\n15331065"}}