2014年4月1日
摘要: /* 前向星数据结构的实现 2014-4-1 21:36:48*/#include #include #include #include #define MAX 10000using namespace std;int head[MAX]; //存储起点为Vi的第一条边的位置struct NODE{ int from, to, w; //起点,终点,权值};NODE edge[MAX];bool cmp(NODE a, NODE b){ if(a.from == b.from && a.to == b.to) return a.w < b.w; if(a.from == 阅读全文
posted @ 2014-04-01 22:18 长木Qiu 阅读(222) 评论(0) 推荐(0) 编辑
摘要: /* 输入菱形的高度n(只能为奇数),输出图形 2014-4-1 18:38:57*/#include #include int main(){ int n, i, j, cen; char ch[2]; do{ printf("请输入菱形的高度:"); scanf("%d", &n); if(n % 2 == 0){ printf("Sorry, 菱形的高度只能是奇数。请重新来过。\n"); continue; } for(i = 1, cen = n / 2 + 1; i <= n; ++i){ for(j = 1; 阅读全文
posted @ 2014-04-01 18:38 长木Qiu 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 原题链接#include int main(){ int n, t, x; while(scanf("%d", &n) == 1){ x = 0; while(n--){ scanf("%d", &t); x ^= t; } printf("%d\n", x); } return 0;} 阅读全文
posted @ 2014-04-01 11:33 长木Qiu 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 原题链接之前WA了两次,都是由于没考虑到0的情况。样例输入2 湖的个数1 小时数10 1 最初5分钟捕鱼数2 5 每5分钟减少的鱼数2 跑路间隔时间*5 min4410 15 20 170 3 4 31 2 34410 15 50 300 3 4 31 2 30样例输出45, 5Number of fish expected: 31240, 0, 0, 0Number of fish expected: 480115, 10, 50, 35Number of fish expected: 724//关键点:求出在第一个湖耗时最长的,所以如果有多余的时间则尽量都耗在第一个湖边//贪心+枚举#in 阅读全文
posted @ 2014-04-01 11:17 长木Qiu 阅读(165) 评论(0) 推荐(0) 编辑
  2014年3月30日
摘要: import java.io.*;public class Main{ public static void main(String[] args){ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String s = null; try{ s = br.readLine(); while(s != null){ if(s.equalsIgnoreCase("exit")) break; System.out... 阅读全文
posted @ 2014-03-30 15:43 长木Qiu 阅读(142) 评论(0) 推荐(0) 编辑
摘要: /* 输入n的值,输出由*组成的高为n的等腰三角形。 2014-3-29 18:46:34*/#include int main(){ int n, i, j, k; char ch[2]; do{ printf("请输入想要打印的等腰三角形的高度n: "); scanf("%d", &n); for(i = 1; i <= n; ++i){ for(j = 1; j <= n; ++j){ if(j <= n - i) putchar(' '); else{ for(k = 0; k != 2 * i - 1; 阅读全文
posted @ 2014-03-30 13:49 长木Qiu 阅读(466) 评论(0) 推荐(0) 编辑
摘要: 原题链接虽然是简单题,但是读懂题要花更长时间。。而且还有些细节要注意。#include int main(){ int sectionNumber, t, ok; double relayDistance; char buf[20]; int teamNumber, teamSeconds, h, m, s; scanf("%d%lf", §ionNumber, &relayDistance); while(scanf("%d", &teamNumber) != EOF){ t = sectionNumber; teamS... 阅读全文
posted @ 2014-03-30 13:22 长木Qiu 阅读(174) 评论(0) 推荐(0) 编辑
  2014年3月27日
摘要: public class Main{ public static void main(String[] args){ if(args.length < 3){ System.out.println("Usage: java Test \"n1\" \"op\" \"n2\""); System.exit(-1); } double d1 = Double.parseDouble(args[0]); double d2 = Double.parseDouble(args[2]); double d = 0; i 阅读全文
posted @ 2014-03-27 20:33 长木Qiu 阅读(322) 评论(0) 推荐(0) 编辑
  2014年3月19日
摘要: class Triangle{ int a = 10, b = 20, c = 25; int Zhouchang(){ return a + b + c; } double Area(){ double p = Zhouchang() / 2.0; return Math.sqrt(p * (p - a) * (p - b) * (p - c)); }}public class hello{ public static void main(String[] args){ Triangle a = new Triangle(); System.out.printf("%d\t%f.. 阅读全文
posted @ 2014-03-19 10:09 长木Qiu 阅读(141) 评论(0) 推荐(0) 编辑
  2014年3月18日
摘要: 原题链接 #include #include int main(){ int m, n, x, y, t; scanf("%d", &m); while(m--){ scanf("%d", &n); x = 0; y = 1; for(int i = 1; (t = (1 + i) * i / 2) #include main(){ int n,m,x,y; scanf("%d\n",&m); while(m--) { scanf("%d",&n); x=(int)(sqrt(2*n 阅读全文
posted @ 2014-03-18 21:45 长木Qiu 阅读(149) 评论(0) 推荐(0) 编辑