北邮oj题库刷题计划(更新ing)

北邮oj题库刷题计划(更新ing)

83. A + B Problem

Calculate the sum of two given integers A and B.

输入格式
The input consists of a line with A and B. (−104≤A,B≤104).

输出格式
Output the only answer.

输入样例
2 3
输出样例
5

#include "stdio.h"
 
int main(){
    int a,b = 0;
    scanf("%d %d", &a,&b);
    int c = a+b;
    printf("%d",c);
    return 0;
}

84 Single Number

Given an array with N integers where all elements appear three times except for one. Find out the one which appears only once.

输入格式
Several test cases are given, terminated by EOF.

Each test case consists of two lines. The first line gives the length of array N(1≤N≤105), and the other line describes the N elements. All elements are ranged in [0,263−1].

输出格式
Output the answer for each test case, one per line.

输入样例
4
1 1 1 3
10
1 2 3 1 2 3 1 2 3 4
输出样例
3
4

不会ing
留个链接先
https://blog.csdn.net/TQCAI666/article/details/88770049

85. Three Points On A Line

题目描述
Given points on a 2D plane, judge whether there’re three points that locate on the same line.

输入格式
The number of test cases T(1≤T≤10) appears in the first line of input.

Each test case begins with the number of points N(1≤N≤100). The following N lines describe the coordinates (xi,yi) of each point, in accuracy of at most 3 decimals. Coordinates are ranged in [−104,104].

输出格式
For each test case, output Yes if there’re three points located on the same line, otherwise output No.

//求大佬帮忙看看哪里有问题,我测试了几组都是对的啊可是编译不过T^T
#include "stdio.h"

int main(){
	int turn;
	scanf("%d",&turn);
	int flag[turn];
	for(int i=0;i<turn;i++){
		int n;
		scanf("%d",&n);
		float a[n][2];
		for(int j = 0;j<n;j++){
			scanf("%f %f",&a[j][0],&a[j][1]);	//读入x,y 
		}
		int k;flag[i]=1;
		for(k=1;k<n-1;k++){
			if((a[k][0]-a[k-1][0])/(a[k][1]-a[k-1][1])!=(a[k+1][0]-a[k][0])/(a[k+1][1]-a[k][1])){
				flag[i]=0;	//斜率不等时为0 
				break;
			}
		}
	} 
	int c;
	for(c=0;c<turn-1;c++){
		if(flag[c]) printf("Yes\n");
		else printf("No\n");
	}
	if(flag[c]) printf("Yes");
		else printf("No");
	return 0} 
发布了16 篇原创文章 · 获赞 6 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_39938635/article/details/103996577