pat
lucas1018
路漫漫其修远兮,吾将上下而求索
展开
-
pat1001:害死人不偿命的(3n+1)猜想
https://www.patest.cn/contests/pat-b-practise/1001#include "stdio.h"int main(){ int n, i = 0; do{ scanf("%d",&n); }while(!(n >= 1)); while(n > 1) { if(0 == n%2) { n = n / 2;原创 2016-03-05 12:25:05 · 290 阅读 · 0 评论 -
pat1022:D进制的A+B
https://www.patest.cn/contests/pat-b-practise/1022#include "stdio.h"int main(){ int a, b, d, i, s, flag = 0; char num[32] = {0}; scanf("%d %d %d", &a, &b, &d); s = a + b; if(0 == s) printf("原创 2016-03-08 13:20:22 · 368 阅读 · 0 评论 -
pat1023:组个最小数
https://www.patest.cn/contests/pat-b-practise/1023#include "stdio.h"int main(){ int i, a[10] = {0}; for(i = 0; i < 10; ++i) scanf("%d", &a[i]); for(i = 1; i < 10; ++i) if(a[i] > 0) {原创 2016-03-08 13:23:57 · 419 阅读 · 0 评论 -
pat1032:挖掘机技术哪家强
https://www.patest.cn/contests/pat-b-practise/1032#include "stdio.h"int main(){ int n, i, num, score, school[100000] = {0}, k, max = 0; scanf("%d", &n); for(i = 0; i < n; ++i) { scanf("%d %原创 2016-03-08 13:27:20 · 555 阅读 · 0 评论 -
pat1026:程序运行时间
https://www.patest.cn/contests/pat-b-practise/1026#include "stdio.h"#define CLK 100int main(){ int a, b, s, f, m, d; scanf("%d %d", &a, &b); d = (int)(1.0 * (b - a) / CLK + 0.5); s = d / 36原创 2016-03-08 13:29:45 · 525 阅读 · 0 评论 -
pat1027:打印沙漏
https://www.patest.cn/contests/pat-b-practise/1027#include "stdio.h"int main(){ int n, j, k, i = 1; char a; scanf("%d %c", &n, &a); while(i*i*2 - 1 <= n) ++i; k = i*2 - 3; for(i = k; i >= 1原创 2016-03-08 13:31:58 · 456 阅读 · 0 评论 -
pat1036:跟奥巴马一起编程
https://www.patest.cn/contests/pat-b-practise/1036#include "stdio.h"int main(){ int n, N, k, i = 0; char c; scanf("%d %c", &n, &c); if(n%2) N = n/2 + 1; else N = n/2; while(i < N) {原创 2016-03-08 13:35:53 · 884 阅读 · 0 评论 -
pat1037:在霍格沃茨找零钱
https://www.patest.cn/contests/pat-b-practise/1037#include "stdio.h"int main(){ int p[3], a[3], j[3]; scanf("%d.%d.%d %d.%d.%d", &p[0], &p[1], &p[2], &a[0], &a[1], &a[2]); if(a[0]*17*29 + a[1]原创 2016-03-09 11:30:02 · 502 阅读 · 0 评论 -
pat1038:统计同成绩学生
https://www.patest.cn/contests/pat-b-practise/1038#include "stdio.h"int main(){ int i, n, k, score, num[101] = {0}; scanf("%d", &n); for(i = 0; i < n; ++i) { scanf("%d", &score); ++num[sc原创 2016-03-09 11:32:35 · 495 阅读 · 0 评论 -
pat1039:到底买不买
https://www.patest.cn/contests/pat-b-practise/1039#include "stdio.h"#include "string.h"int main(){ int i, ky = 0, kn = 0, flag = 0; int numz[62] = {0},numm[62] = {0}; char z[1000], m[1000];原创 2016-03-09 11:35:44 · 429 阅读 · 0 评论 -
pat1040:有几个PAT
https://www.patest.cn/contests/pat-b-practise/1040#include "stdio.h"int main(){ int p = 0, a = 0, t = 0; char c; while(scanf("%c", &c) && ('\n' != c)) { if('P' == c) ++p; else if('A' =原创 2016-03-09 11:40:46 · 544 阅读 · 0 评论 -
pat1041:考试座位号
https://www.patest.cn/contests/pat-b-practise/1041#include "stdio.h"struct{ char id[14]; int p; int q;}stu[1000];int main(){ int i, n, m, s; scanf("%d", &n); for(i = 0; i < n; ++i) sc原创 2016-03-09 11:44:12 · 634 阅读 · 0 评论 -
pat1042:字符统计
https://www.patest.cn/contests/pat-b-practise/1042#include "stdio.h"int main(){ int i, max = 0, k, num[26] = {0}; char ch; while(scanf("%c", &ch) && ('\n' != ch)) { if((ch >= 65) && (ch <=原创 2016-03-09 11:47:40 · 903 阅读 · 0 评论 -
pat1043:输出PATest
https://www.patest.cn/contests/pat-b-practise/1043#include "stdio.h"int main(){ int i, j, max = 0, num[6] = {0}; char ch; while(scanf("%c", &ch) && ('\n' != ch)) { switch(ch) { case 'P原创 2016-03-09 11:50:17 · 1438 阅读 · 0 评论 -
pat1031:查验身份证
https://www.patest.cn/contests/pat-b-practise/1031#include "stdio.h"int main(){ int i, j, n, flag1, flag = 0, sum = 0; char id[100][18]; scanf("%d", &n); for(i = 0; i < n; ++i) scanf("%s",原创 2016-03-10 17:28:09 · 560 阅读 · 0 评论 -
pat1046:划拳
https://www.patest.cn/contests/pat-b-practise/1046#include "stdio.h"int main(){ int n, i, a, b, c, d, p = 0, q = 0; scanf("%d", &n); for(i = 0; i < n; ++i) { scanf("%d %d %d %d", &a, &b, &c原创 2016-03-10 17:30:26 · 551 阅读 · 0 评论 -
pat1021:个位数统计
https://www.patest.cn/contests/pat-b-practise/1021#include "stdio.h"#include "string.h"int main(){ int i, len, a[10] = {0}; char num[1000]; scanf("%s", num); len = strlen(num); for(i = 0; i原创 2016-03-08 13:18:13 · 299 阅读 · 0 评论 -
pat1020:月饼
https://www.patest.cn/contests/pat-b-practise/1020#include "stdio.h"struct yb{ float stock; float price;}yb[1000];void swap(struct yb *a, struct yb *b){ struct yb temp; temp = *a; *a = *b;原创 2016-03-08 13:08:02 · 413 阅读 · 0 评论 -
pat1019:数字黑洞
https://www.patest.cn/contests/pat-b-practise/1019#include "stdio.h"void swap(int *c, int *d){ int temp; temp = *c; *c = *d; *d = temp;}void kap(int k){ int i, j, max, min; int a[4] = {k原创 2016-03-08 13:01:04 · 363 阅读 · 0 评论 -
pat1002:写出这个数
https://www.patest.cn/contests/pat-b-practise/1002#include "stdio.h"int newprint(int s){ int j, a[4]; for(j = 0; s > 0; s/=10) a[j++] = s % 10; while(j-1 >= 0) { switch(a[j-1]) { cas原创 2016-03-05 12:29:10 · 314 阅读 · 0 评论 -
pat1003:我要通过!
https://www.patest.cn/contests/pat-b-practise/1002#include "stdio.h"int check(char str[]){ int t = 0, count1 = 0, count2 = 0, count3 = 0; while('\0' != str[t]) { if(('P' == str[t]) || ('A' =原创 2016-03-07 18:58:13 · 414 阅读 · 0 评论 -
pat1004:成绩排名
https://www.patest.cn/contests/pat-b-practise/1004#include "stdio.h"#define N 100000struct stu{ char name[11]; char num[11]; int score;}stu[N]; int main(){ int n, i; int k = -1, l = -1,原创 2016-03-07 19:04:01 · 1104 阅读 · 0 评论 -
pat1006:换个格式输出整数
https://www.patest.cn/contests/pat-b-practise/1006#include "stdio.h"int main(){ int i, n; scanf("%d", &n); if(n/100 > 0) for(i = 0; i < n/100; ++i) printf("B"); if((n%100)/10 >0) fo原创 2016-03-07 19:07:45 · 598 阅读 · 0 评论 -
pat1007:素数对猜想
https://www.patest.cn/contests/pat-b-practise/1007#include "stdio.h"#include "math.h"int main(){ int i, j, n, temp; int t = 0, k = 0, num[9600] = {0}; scanf("%d", &n); for(i = 2; i <= n; ++i原创 2016-03-07 19:11:04 · 305 阅读 · 0 评论 -
pat1008:数组元素循环右移问题
https://www.patest.cn/contests/pat-b-practise/1008#include "stdio.h"int main(){ int i, N, M, a[100]; scanf("%d %d", &N, &M); M = M % N; for(i = 0; i < N; ++i) scanf("%d", &a[i]); for(i =原创 2016-03-07 19:15:54 · 350 阅读 · 0 评论 -
pat1009:说反话
https://www.patest.cn/contests/pat-b-practise/1009#include "stdio.h"#include "string.h"int main(){ int i, len, k, j = 0, a[80] = {0}; char str[81]; gets(str); len = strlen(str); for(i = 0;原创 2016-03-07 19:19:51 · 1549 阅读 · 0 评论 -
pat1010:一元多项式求导
https://www.patest.cn/contests/pat-b-practise/1010#include "stdio.h"int main(){ int i, num[100] = {0}; for(i = 0; i < 100; ++i) { scanf("%d", &num[i]); if(0 == num[i]) break; } for(i原创 2016-03-07 21:21:55 · 398 阅读 · 0 评论 -
pat1011:A+B和C
https://www.patest.cn/contests/pat-b-practise/1011#include "stdio.h"int main(){ int i = 0, n; long A, B, C; scanf("%d", &n); while(scanf("%ld %ld %ld", &A, &B, &C) != EOF) { if(i++ < n)原创 2016-03-07 21:24:26 · 391 阅读 · 0 评论 -
pat1012:数字分类
https://www.patest.cn/contests/pat-b-practise/1012#include "stdio.h"int main(){ int i, x, n, k = 0, t = 0; int a[5] = {0}, flag[5] = {0}; scanf("%d", &n); for(i = 0; i < n; ++i) { scanf("%原创 2016-03-07 21:28:07 · 563 阅读 · 0 评论 -
pat1013:数素数
https://www.patest.cn/contests/pat-b-practise/1013#include "stdio.h"#include "math.h"int main(){ int n, m, k, i, j, t = 0; int num[10000] = {0}; scanf("%d %d", &n, &m); k = m/n + 1; for(i =原创 2016-03-07 21:33:16 · 488 阅读 · 0 评论 -
pat1014:福尔摩斯的约会
https://www.patest.cn/contests/pat-b-practise/1014#include "stdio.h"#include "string.h"int main(){ int i, k, len[4] = {0}, num[2]; char str[4][60]; for(i = 0; i < 4; ++i) { scanf("%s", str原创 2016-03-08 12:40:45 · 373 阅读 · 0 评论 -
pat1016:部分A+B
https://www.patest.cn/contests/pat-b-practise/1016#include "stdio.h"#include "math.h"int main(){ int a, b, i, k, suma = 0, sumb = 0; char A[11], B[11]; scanf("%s %d %s %d", A, &a, B, &b); fo原创 2016-03-08 12:46:23 · 359 阅读 · 0 评论 -
pat1017:A除以B
https://www.patest.cn/contests/pat-b-practise/1017#include "stdio.h"#include "string.h"int main(){ int b, i, temp = 0, flag = 0; char a[1001]; scanf("%s %d", a, &b); for(i = 0; i < strlen(a)原创 2016-03-08 12:52:49 · 450 阅读 · 0 评论 -
pat1018:锤子剪刀布
https://www.patest.cn/contests/pat-b-practise/1018#include "stdio.h"int main(){ int i, n, kj, ky, maxj = -1, maxy = -1; char jia, yi; int j[6] = {0}, y[6] = {0}; scanf("%d", &n); for(i = 0;原创 2016-03-08 12:56:53 · 397 阅读 · 0 评论 -
pat1047:编程团体赛
https://www.patest.cn/contests/pat-b-practise/1047#include "stdio.h"int main(){ int n, d, c, score, k, maxd = -1, num[1000] = {0}; scanf("%d", &n); while(n--) { scanf("%d-%d %d", &d, &c, &s原创 2016-03-10 17:33:47 · 624 阅读 · 0 评论