好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

北邮计算机院和网院复试上机真题以及参考代码.docx

29页
  • 卖家[上传人]:工****
  • 文档编号:425181091
  • 上传时间:2023-05-24
  • 文档格式:DOCX
  • 文档大小:47.20KB
  • / 29 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 第一题:查找输入数组长度 n 输入数组 a[1...n]输入查找个数 m输入查找数字 b[1...m]输出 YES or NO 查找有则 YES 否则 NO如(括号内容为注释) 输入: 5(数组长度) 1 5 2 4 3(数组 ) 3(查找个数) 2 5 6(查找具体数字 ) 输出:YESYESNO#include #include int main(){int n,m,i,j,a[2001]={0},b[2001]={0},flag=0; scanf("%d",&n);for(i=0;i#include int main(int argc, char *argv[]){int n,k,i,j,a[1001],temp,m=1; scanf("%d %d",&n,&k); for(i=0;ia[j+1]){temp=a[j]; a[j]=a[j+1]; a[j+1]=temp;}for(i=0;iint main(void){char str1[100],str2[5];scanf("%s",str1);char ch;ch=getchar();scanf("%s",str2);int i=0;int count[10]={0};while(str1[i]!='\n'){if((str1[i]-'1')==0) count[0]++;if((str1[i]-'1')==1)count[1]++;if((str1[i]-'1')==2)count[2]++;if((str1[i]-'1')==3)count[3]++;if((str1[i]-'1')==4)count[4]++;if ((str1[i]-'1')==5)count[5]++;if((str1[i]-'1')==6)count[6]++;if((str1[i]-'1')==7)count[7]++;if((str1[i]-'1')==8)count[8]++;break;elseelseelseelseelseelseelseelseelseif(strlen(str2)==1) { s1=*str2-'1';for(;s1<9;s1++)if(count[s1+1]>0) {printf("YES\n",s1);flag=0;break;}else if(strlen(str2)==2) {s2=*str2-'1'; for(;s2<9;s2++)if(count[s2+1]>=2) {printf("YES\n",s2);flag=0;break;} }else if(strlen(str2)==3) {s3=*str2-'1'; for(;s3<9;s3++)if(count[s3+1]>=3) {printf("YES\n");flag=0;break;} }else if(strlen(str2)==4) {s4=*str2-'1'; for(;s4<9;s4++)if(count[s4+1]>=4) {printf("YES\n");flag=0;break;} }else if(strlen(str2)==5){s5=*str2-'1'; for(;s5<9;s5++) if(count[s5+5]>0&&count[s5+1]>0&&count[s5+2]>0&&count[s5+3]>0&&count [s5+4]>0&&((s5+5)<9)) {printf("YES\n");flag=0;break;}}if(flag==1) printf("NO\n");// system("PAUSE");return EXIT_SUCCESS;第四题:树 查找 简单说就是一棵树,输出某一深度的所有节点,有则输出这些节点,无则输出EMPTY,具体描述得借助图形比较好,懒得写了,基本就是这个样子的。

      2010 计算机学院上机题目回忆版ACMBOJ——2010 年北邮计算机学院研究生入学考试(复试)上机测试一一即1814 (A比较奇 偶数个数)、1815 (B找最小数)、1816 (C翻转)、 1817(D哈夫曼树)因为 boj 上题目都已经看不到了所以题目只能是回忆版 但 boj 上仍然可以提交所有知道题意以后,仍然可以自己 进行测试题目大意(回忆版):第一行输入一个数,为n第二行输入 n 个数,这 n 个数中,如果偶数比奇数多,输出 NO ,否则输 出 YES Sample:Input:51 2 3 4 5Output:YESProblem Id: 1814Submit time: 2010-04-10 14:06:48User_id: bupt111310352Memory:72K Time:17MSLanguage:G++ Result:AcceptedCode*/#include int main(){// 所有数的数目int m_Num_Count;scanf("%d", &m_Num_Count);// 输入数 int m_Input_Num;// 偶数 奇数的个数int m_Oushu_Count = 0, m_Jishu_Count = 0;// 循环输入 while(m_Num_Count > 0){scanf("%d", &m_Input_Num); getchar();// 判断奇偶并计数if( (m_Input_Num % 2) == 0 )++ m_Oushu_Count; else++ m_Jishu_Count;-- m_Num_Count;}// 输出 if(m_Jishu_Count >= m_Oushu_Count) printf("YES\n");elseprintf("NO\n");return 0;}/*题目大意(回忆版):第一行输入一个数 n,1 <= n <= 1000下面输入n行数据,每一行有两个数,分别是x y。

      输出一 组x y,该组数据是所有数据中x最小,且在x相等的情况 下 y 最小的Sample:Input:53 32 25 52 13 6Output:Problem Id: 1815Submit time: 2010-04-10 14:24:39User_id: bupt111310352 Memory:104K Time:19MS Language:G++ Result:AcceptedCode*/#include typedef struct LNode{int m_X; // x 坐标值int m_Y; // y 坐标值bool m_Used; // 该位是否被使用 };int main(){// 样例个数int m_Case_Count;scanf( "%d", &m_Case_Count );// 因为 1 <= N <= 1000,建结点LNode m_Case[ 1000 ];// 循环数int m_Cycle;// 最小的 x, y 值,并初始化, 1 <= x,y <= 1000 int m_X_Min = 1000, m_Y_Min = 1000;// 初始化结点被使用状态for( m_Cycle = 0; m_Cycle < 1000; ++ m_Cycle ) m_Case[ m_Cycle ].m_Used = false;// 初始化循环数,下面使用m_Cycle = 0;// 循环输入样例while( m_Case_Count > 0 )// 输入坐标值scanf( "%d %d", &m_Case[ m_Cycle &m_Case[ m_Cycle ].m_Y );// 置状态值,并且 m_Cycle ++m_Case[ m_Cycle ++ ].m_Used = true;-- m_Case_Count;}// 循环找最小的 x,y 值for( m_Cycle = 0; ( m_Cycle < 1000( m_Case[ m_Cycle ].m_Used ) ; ++ m_Cycle ){if( m_Case[ m_Cycle ].m_X < m_X_Min ){// 如果找到更小的 x 值,记录m_X_Min = m_Case[ m_Cycle ].m_X;m_Y_Min = m_Case[ m_Cycle ].m_Y;}].m_X,) &&Min )else if ( m_Case[ m_Cycle ].m_X == m_X_// 如果 x 值相等,判断 y 值, 如果在相等的 x 值的条件下,找。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.