cjweffort

博客园 首页 联系 订阅 管理

2013年3月2日

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=18题目描述:在一个整数数组上,对于下标为i的整数,如果它大于所有它相邻的整数,或者小于所有它相邻的整数,则称为该整数为一个极值点,极值点的下标就是i。输入:每个案例的输入如下:有2×n+1行输入:第一行是要处理的数组的个数n;对其余2×n行,第一行是此数组的元素个数k(4 using namespace std; const int N=83; int a[N]; int main() { int testCase; cin>>testCase; while(te 阅读全文
posted @ 2013-03-02 12:08 cjweffort 阅读(339) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=19题目描述:输入数组长度 n输入数组 a[1...n]输入查找个数m输入查找数字b[1...m]输出 YES or NO 查找有则YES 否则NO 。输入:输入有多组数据。每组输入n,然后输入n个整数,再输入m,然后再输入m个整数(1 #include using namespace std; const int N=103; int a[N]; int binarySearch(int num, int low, int high) { if(low>high) return -1; i 阅读全文
posted @ 2013-03-02 12:08 cjweffort 阅读(164) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=17题目描述:输入N个学生的信息,然后进行查询。输入:输入的第一行为N,即学生的个数(N #include #include using namespace std; const int N=1003; typedef struct STU { char no[8]; char name[100],sex[6]; int age; }STU; STU stu[N]; bool cmp(STU m1, STU m2) { return strcmp(m1.no,m2.no)high) r... 阅读全文
posted @ 2013-03-02 12:08 cjweffort 阅读(160) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=15题目描述:Harmony is indispensible in our daily life and no one can live without it----may be Facer is the only exception. One day it is rumored that repeat painting will create harmony and then hundreds of people started their endless drawing. Their pai 阅读全文
posted @ 2013-03-02 12:07 cjweffort 阅读(193) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=14题目描述:把一个个大小差一圈的筐叠上去,使得从上往下看时,边筐花色交错。这个工作现在要让计算机来完成,得看你的了。输入:输入是一个个的三元组,分别是,外筐尺寸n(n为满足0 #include const int N=81; bool tag[N][N]; int main() { freopen("F:\\test.txt","r",stdin); freopen("F:\\output.txt","w",stdo 阅读全文
posted @ 2013-03-02 12:07 cjweffort 阅读(186) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=13题目描述:输入一个高度h,输出一个高为h,上底边为h的梯形。输入:一个整数h(1 #include int main() { int n; while(scanf("%d",&n)!=EOF) { int count=n+2*(n-1); for(int i=1;i<=n;i++) { int tmp=count-(n+2*(i-1)); for(int j=1;j<=tmp;j++) printf(" "); for(int j=t 阅读全文
posted @ 2013-03-02 12:06 cjweffort 阅读(178) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=16题目描述:输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数组中则输出-1)。输入:测试数据有多组,输入n(1 using namespace std; const int N=203; int a[N]; int main() { int n; while(cin>>n) { for(int i=0;i>a[i]; int tmp; cin>>tmp; bool flag=true; for(int i=0; 阅读全文
posted @ 2013-03-02 12:06 cjweffort 阅读(178) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=11题目描述: “臭味相投”——这是我们描述朋友时喜欢用的词汇。两个人是朋友通常意味着他们存在着许多共同的兴趣。然而作为一个宅男,你发现自己与他人相互了解的机会并不太多。幸运的是,你意外得到了一份北大图书馆的图书借阅记录,于是你挑灯熬夜地编程,想从中发现潜在的朋友。 首先你对借阅记录进行了一番整理,把N个读者依次编号为1,2,…,N,把M本书依次编号为1,2,…,M。同时,按照“臭味相投”的原则,和你喜欢读同一本书的人,就是你的潜在朋友。你现在的任务是从这份借阅记录中计算出每个人有几个潜在朋友。输 阅读全文
posted @ 2013-03-02 12:06 cjweffort 阅读(213) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=10题目描述:给你n个整数,请按从大到小的顺序输出其中前m大的数。输入:每组测试数据有两行,第一行有两个数n,m(0 #include #include #include #include #include #include #include #include #include #include using namespace std; const int N=1000003; bool hashTable[N]; #define more 500000 int main() { ... 阅读全文
posted @ 2013-03-02 11:37 cjweffort 阅读(124) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=12题目描述: 有一个长度为整数L(1 #include #include #include #include #include #include #include #include #include #include using namespace std; const int N=10003; int hashTable[N]; int main() { //freopen("F:\\test.txt","r",stdin); //freopen(&qu 阅读全文
posted @ 2013-03-02 11:37 cjweffort 阅读(186) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=9题目描述:读入N名学生的成绩,将获得某一给定分数的学生人数输出。输入:测试输入包含若干测试用例,每个测试用例的格式为第1行:N第2行:N名学生的成绩,相邻两数字用一个空格间隔。第3行:给定分数当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。输出:对每个测试用例,将获得给定分数的学生人数输出。样例输入:3 80 60 90 60 2 85 66 0 5 60 75 90 55 75 75 0样例输出:1 0 2// 题目10:统计同成绩学生人数.cpp: 阅读全文
posted @ 2013-03-02 11:31 cjweffort 阅读(216) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=8题目描述:给出年分m和一年中的第n天,算出第n天是几月几号。输入:输入包括两个整数y(1 int isLeap(int year) { return (year%4==0&&year%100!=0||year%400==0)?1:0; } void printDate(int *mDay,int year,int nDays) { int month=1,day; int tag=isLeap(year); if(tag) mDay[2]+=1; while(nDays>m 阅读全文
posted @ 2013-03-02 11:25 cjweffort 阅读(148) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=7题目描述:输入年、月、日,计算该天是本年的第几天。输入:包括三个整数年(1 int Runyear(int yy) { if(yy%4==0&&(yy%100!=0||yy%400==0)) return 1; return 0; } int Count(int yy,int mm,int dd) { int sum=0; if(mm>1) sum+=31; if(mm>2) if(Runyear(yy)) ... 阅读全文
posted @ 2013-03-02 11:22 cjweffort 阅读(152) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=6题目描述:We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400.For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap.Your ta 阅读全文
posted @ 2013-03-02 11:22 cjweffort 阅读(168) 评论(0) 推荐(0) 编辑

摘要: // 题目6:日期差值.cpp: 主项目文件。 #include "stdafx.h" #include int mDay[13]={31,28,31,30,31,30,31,31,30,31,30,31}; int mYear[2]={365,366}; int isLeap(int year) { return (year%4==0&&year%100!=0||year%400==0)?1:0; } int days(int yy,int mm,int dd) { int res=0; for(int i=1;i<mm;i++) res+=mDay 阅读全文
posted @ 2013-03-02 11:13 cjweffort 阅读(156) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=3题目描述: Excel可以对一组纪录按任意指定列排序。现请你编写程序实现类似功能。 对每个测试用例,首先输出1行“Case i:”,其中 i 是测试用例的编号(从1开始)。随后在 N 行中输出按要求排序后的结果,即:当 C=1 时,按学号递增排序;当 C=2时,按姓名的非递减字典序排序;当 C=3时,按成绩的非递减排序。当若干学生具有相同姓名或者相同成绩时,则按他们的学号递增排序。输入: 测试输入包含若干测试用例。每个测试用例的第1行包含两个整数 N (N #include #include # 阅读全文
posted @ 2013-03-02 11:12 cjweffort 阅读(205) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=4题目描述:输入一个字符串,长度小于等于200,然后将输出按字符顺序升序排序后的字符串。输入:测试数据有多组,输入字符串。输出:对于每组输入,输出处理后的结果。样例输入:bacd样例输出:abcd// 题目5:字符串内排序.cpp: 主项目文件。 #include "stdafx.h" #include #include #include #include #include #include #include #include #include #include #includ 阅读全文
posted @ 2013-03-02 11:11 cjweffort 阅读(224) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=2题目描述:输入一系列整数,将其中最大的数挑出,并将剩下的数进行排序。输入:输入第一行包括1个整数N,1 #include #include using namespace std; const int N=1003; int a[N]; int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d",a+i); sort(a,a+n); if(n 阅读全文
posted @ 2013-03-02 11:05 cjweffort 阅读(183) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=1题目描述: 有N个学生的数据,将学生数据按成绩高低排序,如果成绩相同则按姓名字符的字母序排序,如果姓名的字母序也相同则按照学生的年龄排序,并输出N个学生排序后的信息。输入: 测试数据有多组,每组输入第一行有一个整数N(N #include #include using namespace std; const int N=1003; typedef struct STU { char name[101]; int age,score; }STU; STU stu[N]; bool cmp(... 阅读全文
posted @ 2013-03-02 11:03 cjweffort 阅读(315) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=0题目描述: 对输入的n个数进行排序并输出。输入: 输入的第一行包括一个整数n(1 #include using namespace std; const int N=103; int a[N]; int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d",a+i); sort(a,a+n); for(int i=0;i<n;i++) { 阅读全文
posted @ 2013-03-02 10:59 cjweffort 阅读(210) 评论(0) 推荐(0) 编辑