PAT-B 刷题(1)

1001~1005

1001 害死人不偿命的(3n+1)猜想 (15分)

#include<stdio.h>

int main()
{
	int n,count;
	scanf("%d", &n);
	while(n != 1){
		if(n%2 == 0){
			n = n/2;
		}
		else{
			n = (3*n + 1)/2;
		}
		count++;
	}
	printf("%d",count);
	return 0;
}
1011 A+B 和 C (15分)

#include<stdio.h>
int main(){
    int num,sec=1;
    scanf("%d\n",&num);
    while(num--){
        long long a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        if(a+b>c){
            printf("Case #%d: true\n",sec++);
        }else{
            printf("Case #%d: false\n",sec++);
        }
    }
    return 0;
}
posted @ 2020-02-21 16:02  ExplodedVegetable  阅读(106)  评论(1编辑  收藏  举报