c语言复习资料.doc

上传人:s9****2 文档编号:559602681 上传时间:2022-11-27 格式:DOC 页数:3 大小:26.51KB
返回 下载 相关 举报
c语言复习资料.doc_第1页
第1页 / 共3页
c语言复习资料.doc_第2页
第2页 / 共3页
c语言复习资料.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《c语言复习资料.doc》由会员分享,可在线阅读,更多相关《c语言复习资料.doc(3页珍藏版)》请在金锄头文库上搜索。

1、c语言复习资料今天下午的两道面试题 1。 一人岁数的3次方是四位数,四次方是六位数,并知道此人岁数的3次方和4次方用遍了09十个数字。编写一程序求此人的岁数。 2。对1,2,3, 4, 5 这五个数任意取出两个数,列出他们的所有组合。 public static int getAge() int age; int third; int fourth; for (int i = 11; true; i+) if (i 200) third = (int) Math.pow(i, 3); fourth = (int) Math.pow(i, 4); if (getLength(third, fou

2、rth) = 10) age = i; break; return age; public static int getLength(int args1, int args2) String str1 = String.valueOf(args1); String str2 = String.valueOf(args2); String str = str1 + str2; if (str.length() != 10) return -1; int intarray = new int10; for (int i = 0; i str.length(); i+) intarray = Int

3、eger.parseInt(str.substring(i,i+1); Arrays.sort(intarray); if(intarray0!=0 & intarray9!=9) return -1; return 10; http:/ 第二题还更简单了 for(int i=1; i6; i+) for(int j=1; j6; j+) if(i=j) System.out.println(j+j); else System.out.println(i+j); System.out.println(j+i); public class A / http:/ . 929.xml?temp=.5

4、7922 public static void main(String args) String t; String s = new String5; int j = s.length; for(int i=0; ij; i+) s = new Integer(i+1).toString(); for(int i=0; ij; i+) t = s; for(int a=0; aj; a+) t += s; System.out.println(t); System.out.println(); http:/ for(int i=1; i6; i+) for(int j=1; j6; j+) i

5、f(i=j) System.out.println(j+j); else System.out.println(i+j); System.out.println(j+i); = http:/ 4, 5 这五个数任意取出两个数,列出他们的所有组合,所以重复的数字不应该算在里面。 第二题应该改为: for(int i=1; i6; i+) for(int j=1; j6; j+) if(i=j) break; else System.out.println(i+j); System.out.println(j+i); public class B public static void main(S

6、tring args) for (int i = 1; i 6; i+) int t = i; for(int a = 0; a5; a+) int c = a+1; if(c = t) continue; else System.out.println(t*10+c); System.out.println(); 第二题 public class Test public static void main(String args) int a=new int5; for(int i=0;ia.length;i+) a=new inti+1; for(int i=1;i=a.length;i+)

7、 for(int j=i+1;j0;i-) for(int j=i-1;j0;j-) System.out.print(i); System.out.print(j+ ); System.out.print( ); public class Test public static int getDigits(String str) int intarr = new int10; for (int i = 0; i 10; i+) intarr = 0; for (int i = 0; i str.length(); i+) int j = Integer.parseInt(str.substri

8、ng(i, i + 1); intarrj = 1; int num = 0; for (int i = 0; i 10; i+) num = num + intarr; return num; private static int getAge() int age; int third; int fourth; for (age = 1; age 100; age+) third = (int) Math.pow(age, 3); fourth = (int) Math.pow(age, 4); if (third = 10000) continue; if (fourth = 100000

9、0) continue; String str = String.valueOf(third) + String.valueOf(fourth); if (getDigits(str) = 10) return age; return 0; 更多c语言学习资料:http:/ 第二道题 class Combine public static void main(String args) for(int i=1; i5; i+) for(int j=i+1; j6; j+) System.out.println(i+j); System.out.println(j+i); public class

10、 Age public static void main(String args) String str1 = null; String str2 = null; String str3 = null; String str4 = 0123456789; for(int i=10;i50;i+) str1 = Integer.toString(i*i*i); str2 = Integer.toString(i*i*i*i); str3 = str1+str2; if(str1.length() = 4) & (str2.length() =6) boolean flag = true; for(int j=0;j+i); System.out.println(str3);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号