1. 程式人生 > >PAT B1046. 划拳(%%d錯誤)

PAT B1046. 划拳(%%d錯誤)

划拳是古老中國酒文化的一個有趣的組成部分。酒桌上兩人划拳的方法為:每人口中喊出一個數字,同時用手比劃出一個數字。如果誰比劃出的數字正好等於兩人喊出的數字之和,誰就贏了,輸家罰一杯酒。兩人同贏或兩人同輸則繼續下一輪,直到唯一的贏家出現。

下面給出甲、乙兩人的划拳記錄,請你統計他們最後分別喝了多少杯酒。

輸入格式:

輸入第一行先給出一個正整數N(<=100),隨後N行,每行給出一輪划拳的記錄,格式為:

甲喊 甲劃 乙喊 乙劃

其中“喊”是喊出的數字,“劃”是劃出的數字,均為不超過100的正整數(兩隻手一起劃)。

輸出格式:

在一行中先後輸出甲、乙兩人喝酒的杯數,其間以一個空格分隔。

輸入樣例:
5
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
輸出樣例:
1 2

思路:喵的沒思路,因為多打了個%,%%d,查了一個小時都沒查出來錯誤,森氣

#include <cstdio>

int main(){
	int faila=0,failb=0;
	int n;
	
	scanf("%d",&n);
	
	while(n--){ 
		int a1,a2,b1,b2;
		scanf("%d%d%d%d",&a1,&a2,&b1,&b2);//這裡寫成了%%d,多打了%沒有報錯,程式卻像喝醉一樣輸出結果,查了一個小時 
		if(a2 == a1+b1 && a2 != b2){
			failb++;
		}
		else if(b2 == a1+b1 && a2 != b2) faila++;
	}
	
	printf("%d %d",faila,failb);
	return 0;
} 

相關推薦

PAT B1046. %%d錯誤

划拳是古老中國酒文化的一個有趣的組成部分。酒桌上兩人划拳的方法為:每人口中喊出一個數字,同時用手比劃出一個數字。如果誰比劃出的數字正好等於兩人喊出的數字之和,誰就贏了,輸家罰一杯酒。兩人同贏或兩人同輸則繼續下一輪,直到唯一的贏家出現。下面給出甲、乙兩人的划拳記錄,請你統計他們最後分別喝了多少杯酒。輸入格式:輸

PAT (Basic Level) Practice 中文 1046 15 分 C++

1046 划拳 (15 分) 划拳是古老中國酒文化的一個有趣的組成部分。酒桌上兩人划拳的方法為:每人口中喊出一個數字,同時用手比劃出一個數字。如果誰比劃出的數字正好等於兩人喊出的數字之和,誰就贏了,輸家罰一杯酒。兩人同贏或兩人同輸則繼續下一輪,直到唯一的贏家出現。 下面給出甲、乙

1046 15 分

划拳是古老中國酒文化的一個有趣的組成部分。酒桌上兩人划拳的方法為:每人口中喊出一個數字,同時用手比劃出一個數字。如果誰比劃出的數字正好等於兩人喊出的數字之和,誰就贏了,輸家罰一杯酒。兩人同贏或兩人同輸則繼續下一輪,直到唯一的贏家出現。 下面給出甲、乙兩人的划拳記錄,請你統計他們最後分

pat 1015 Reversible Primes20 分

clu output tex one prim ron lang pos max 1015 Reversible Primes(20 分) A reversible prime in any number system is a prime whose "revers

pat 1046 Shortest Distance20 分 (線段樹)

ns2 imp turn for lse struct any ner max 1046 Shortest Distance(20 分) The task is really simple: given N exits on a highway which forms

pat 1042 Shuffling Machine20 分

spa sid stack lin pre using vector urn tex 1042 Shuffling Machine(20 分) Shuffling is a procedure used to randomize a deck of playing c

pat 1108 Finding Average20 分

tst puts ram final aaa alc ont pri const 1108 Finding Average(20 分) The basic task is simple: given N real numbers, you are supposed t

pat 1100 Mars Numbers20 分

examples earch clas fir other mutual form Language for 1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero

1046 劃15 分

tex 0.10 else ng- tom spa esp 等於 col 劃拳是古老中國酒文化的一個有趣的組成部分。酒桌上兩人劃拳的方法為:每人口中喊出一個數字,同時用手比劃出一個數字。如果誰比劃出的數字正好等於兩人喊出的數字之和,誰就贏了,輸家罰一杯酒。兩人同贏或兩人

jchdl - GSL實例 - DFlipFlopD觸發器

方法 order clas del dom 構造方法 spa attach 靜態 https://mp.weixin.qq.com/s/7N3avTxTd2ZUnAcKg4w3Ig D觸發器對邊沿敏感,只有當相應的邊沿出現時,才會觸發D的值傳播到輸出Q。 ?? 引

【笨方法學PAT】1010 Radix25 分

一、題目 Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal numbe

【笨方法學PAT】1008 Elevator20 分

一、題目 The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at wh

關於composer拉取報錯的問題ssl錯誤

錯誤資訊: The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you c

PAT——A1030 Travel Plandijkstra演算法

題目連結: #include<iostream> #include<set> #include<string> #include<cmath> #include<cstring> #include<algorithm> #i

python scrapy 儲存資料到mysql的坑1064錯誤

在將scrapy中的資料儲存到mysql中,出現部分資料插入不進去的問題, 一直報: You have an error in your SQL syntax; mysql相對於mongo來說,對資料要嚴格些,有時候,很多SQL語句寫對了,還是插不進去資料。針對上面的問題,我使

PAT 1051 Pop Sequence 25 分

1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are

PAT 1100 Mars Numbers 20 分

1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called “tret” on Mars. The numbers 1 to 12 on Earch is

PAT 1063 Set Similarity 25 分

1063 Set Similarity (25 分) Given two sets of integers, the similarity of the sets is defined to be

PAT 1022 Digital Library 30 分

1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstract

PAT 1084 外觀數列 20 分C語言版

1084 外觀數列 (20 分) 解題思路: 設定兩個陣列,分別存放相鄰兩個序列,其中s1存放前一個,s2存放後一個,首先可確定的是兩個陣列的第一個元素,即s1[0] = s2[0] = d。 從s1得到s2:如果s1[i] == s1[i-1]的話,那計數cnt