NY12.20程序设计

1.hello world

有手就行

2.a+b

记得开long long

#include<stdio.h>
int main()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld",a+b);
 } 

3.判断奇偶

#include<stdio.h>
#include<string.h>
int main()
{
	char a[100000];
	scanf("%s",a);
	int i=strlen(a);
	if(a[i-1]=='0' ||a[i-1]=='2' ||a[i-1]=='4' ||a[i-1]=='6' ||a[i-1]=='8')
	printf("oushu");
	else
	printf("jishu");
 } 

4.统计字母

#include<stdio.h>
#include<string.h>
int b[30];
int main()
{
   char a[100000];
   scanf("%s",a);
   int l=strlen(a);
   for(int i=0;i<l;i++)
   {
   	b[a[i]-'a']++;
   }
   for(int i=0;i<26;i++)
   printf("%d ",b[i]);
} 

5.分数求和

#include<stdio.h>
int main()
{
   double n,ans=0;
   scanf("%lf",&n);
   for(int i=1;i<=n;i++)
   {
   	ans+=(1/double(i));
   }
   printf("%.6lf",ans);
} 

6.罚时

题意:给俩时间,一个代表开始时间,一个代表结束时间,时间差为发誓,其中字符D为俩时间同一天,N为差一天。最后一个数字为错误次数,错一次加20分钟罚时,求总罚时
例如:08:00 D 09:00 2
意思为当天八点开始九点结束,共60min,加上2次罚时40min共计100min。

#include<stdio.h>
int main()
{
   int h1,h2,h3=24,m1,m2,m3=0,ans=0,t;
   char a;
   scanf("%d:%d",&h1,&m1);
   getchar();
   scanf("%c",&a);
   scanf("%d:%d",&h2,&m2);
   scanf("%d",&t);
   ans+=t*20;
   if(a=='D')
   {
   	ans+=(h2-h1)*60;
   	ans+=(m2-m1);
   }
   else
   {
   	ans+=(h3-h1)*60;
   	ans+=(m3-m1);
   	ans+=h2*60+m2;
   }
   printf("%d",ans);
} 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值