天梯赛1.26

L1-031 到底是不是太胖了

#include <stdio.h>
#include <math.h>
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int h, w;
		scanf("%d %d", &h, &w);
		float stan = (h - 100) * 0.9 * 2;
		if (fabs(w - stan) < stan * 0.1)
			printf("You are wan mei!\n");
		else if (stan < w)
			printf("You are tai pang le!\n");
		else
			printf("You are tai shou le!\n");
	}

	return 0;
}

L1-032 Left-pad

#include<stdio.h>
#include<string.h>
int main(){
    char a[100000],b;
    int n,i;
    scanf("%d %c",&n,&b);
    getchar();
    scanf("%[^\n]",a);
    if(strlen(a)>n)
        for(i=strlen(a)-n;i<strlen(a);i++)
            printf("%c",a[i]);
    else{
        for(i=0;i<n-strlen(a);i++)
            printf("%c",b);
        for(i=0;i<strlen(a);i++)
            printf("%c",a[i]);
    }
}

L1-033 出生年

#include <stdio.h>
int main()
{
	int cs[4];//存出生日期
	int a,b,i;
	scanf("%d %d",&a,&b);
	for(i=a;i<3100;i++)
	{
		int cnt=1;//记录不同数字的个数,所有的数字都相同
		cs[0]=i/1000;
		cs[1]=i/100%10;
		cs[2]=i/10%10;
		cs[3]=i%10;
		if(cs[0]!=cs[1]&&cs[0]!=cs[2]&&cs[0]!=cs[3])
		cnt++;//两个数字不同
		if(cs[1]!=cs[2]&&cs[1]!=cs[3])
		cnt++;//三个数字不同
		if(cs[2]!=cs[3])
		cnt++;
		if(cnt==b)
		break;
	}
	printf("%d %04d",i-a,i);
	return 0; 
}

L1-034 点赞

#include<stdio.h>
int main() 
{
    int n, k, num, max1= 0, max2= 0;
    scanf("%d", &n);
    int arr[1001] = {0};
    for (int i=0;i<n;i++) 
    {
        scanf("%d", &k);
        for (int j=0;j<k;j++) 
        {
            scanf("%d", &num);
            arr[num]++; 
        }
    }
    for (int i=0;i<1001;i++)
     {
        if (arr[i] >= max1)
         {
            max1= arr[i];
            max2= i;
        }
    }
    printf("%d %d",max2,max1);
    return 0;
}

L1-035 情人节

#include<stdio.h>
#include<string.h>
char a[10000][20];
int main()
{
    int cnt=0;
    while(scanf("%s",a[cnt])&&a[cnt][0]!='.')
    {
        cnt++;
    }
    if(cnt<2)
    printf("Momo... No one is for you ...\n");
    else if(cnt<14)
    printf("%s is the only one for you...\n",a[1]);
    else 
    printf("%s and %s are inviting you to dinner...\n",a[1],a[13]);
}

蓝桥杯 最大子矩阵

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  // 请在此输入您的代码
  char b[20][21]={
"69859241839387868941",
"17615876963131759284",
"37347348326627483485",
"53671256556167864743",
"16121686927432329479",
"13547413349962773447",
"27979945929848824687",
"53776983346838791379",
"56493421365365717745",
"21924379293872611382",
"93919353216243561277",
"54296144763969257788",
"96233972513794732933",
"81443494533129939975",
"61171882988877593499",
"61216868895721348522",
"55485345959294726896",
"32124963318242554922",
"13593647191934272696",
"56436895944919899246",
};
int a[20][20];
for(int i=0;i<20;i++){
        for(int j=0;j<20;j++){
            a[i][j]=b[i][j]-'0';
        }
    }
    int m=0;
    for(int i=0;i<20-5;i++){
        for(int j=0;j<20-5;j++){
            int s=0;
            for(int i1=i;i1<i+5;i1++){
                for(int j1=j;j1<j+5;j1++){
                    s+=a[i1][j1];
                }
            }
            if(s>m){
                m=s;
            }
        }
    }
    printf("%d",m);
  return 0;
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值