摘要:
一、输入:1、while (scanf("%d", &n) , n)//表示只有当n=0时输入结束。2、while(m--&&scanf("%d",&n))//表示m为多少值就输入几个n。3、关于gets()输入函数,遇到\n,会把\n当作\0结束。遇到空格则会把空格读入该字符串中。二、输出:1、printf(count++?“ %d”:"%d",i)//表示如果count为0则执行“%d”,否则执行“ %d”。该种情况用于不知道什么时候输出结束,而且对输入格式有要求,即输出的每两个数字之间有空格但最后 阅读全文
posted @ 2012-07-27 20:29
zhtzhl
阅读(230)
评论(0)
推荐(0)
摘要:
这道题不难,但是自己用switch,很烦参考码中有个不错的办法 #include <math.h>#include <stdio.h>#define lev(n) ((n % 4 == 0 && n % 100 != 0) ||( n % 400 == 0))//((n % 4 == 0 && n % 100 != 0) ||( n % 400 == 0))的值是1或0.int main(void){ int y, m, d, i, s; int month[2][13] = { {0, 31, 28, 31, 30, 31, 30, 3 阅读全文
posted @ 2012-07-27 19:56
zhtzhl
阅读(132)
评论(0)
推荐(0)
摘要:
这道题很简单,但却值得写一下结题报告。因为:1、当定义了字符后,可直接a>b,否则若用'a'>'b',则说明是a本身这个字符,而不是变量了2、三个比大小,顺序很重要,先是a与b比,然后是a与c比,最后是b与c比。这里的交换如a与b,是指a与b的大小变了,交换了a与b的值。因为a与b是变量,而不是指交换过后a与b的位置也变了,所以输出时是a、b、c的顺序。#include<stdio.h>int main(){char a,b,c,t;while(scanf("%c%c%c",&a,&b,&c)! 阅读全文
posted @ 2012-07-27 18:34
zhtzhl
阅读(340)
评论(0)
推荐(0)
摘要:
#include<vector>#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;#define Min(a,b) a>b?b:a#define M 10010 //题目中可能的最大点数vector <int> Edge[M]; //图用邻接表表示int STACK[M],top=0; //Tarjan 算法中的栈bool InStack[M]; //检查是否在栈中int DFN[M] 阅读全文
posted @ 2012-07-27 18:25
zhtzhl
阅读(239)
评论(0)
推荐(0)
浙公网安备 33010602011771号