博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ题目(11.22-12.22)
阅读量:4588 次
发布时间:2019-06-09

本文共 4924 字,大约阅读时间需要 16 分钟。

HDOJ题目(11.22-12.22)

[TOC]

 

 

 

 

hdoj_2000

注意getchar的用方法,按照以上的输入之后,处理三个字符以外还会有换行符

 

#include
#include
#include
#include
using namespace std;int main(){ char arr[3]; while(scanf("%c%c%c",&arr[0],&arr[1],&arr[2])!=EOF) { //cout<

 

hdoj_2002

 

#include
#include
#include
#include
#include
#define PI 3.1415927using namespace std;int main(){ //double精度高,有效数字16位,float精度7位 //用double才够表示,不然会溢出 double r; double rst; while(scanf("%lf",&r)!=EOF) { rst=(4/3.0)*PI*pow(r,3);//注意一定要3.0或者4.0,不然3/4=1 printf("%.3lf\n",rst); }}

 

 

hdoj_2005

会忘记归0很不好

#include
#include
#include
#include
#include
using namespace std;int main(){ int year,month,day; char ch; int arr1[13]={
0,31,28,31,30,31,30,31,31,30,31,30,31}; int arr2[13]={
0,31,29,31,30,31,30,31,31,30,31,30,31}; while(scanf("%d%c%d%c%d",&year,&ch,&month,&ch,&day)!=EOF) { int rst=0; //算完一次要归0 if(year%400==0 ||(year%4==0 && year%100!=0))//闰年 { for(int i=0;i

 

 

hdoj_2006

 

#include
#include
#include
#include
#include
using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF) { int arr[10000];//不可以用int arr[n]本地正确,但是oj会编译出错 long long rst=1; for(int i=0;i

 

 

hdoj_2007

#include
#include
#include
#include
#include
using namespace std;int main(){ int L,R; while(scanf("%d %d",&L,&R)!=EOF) { long long rst1=0,rst2=0; if(L>R) swap(L,R) ;//坑点在此,题目没有明说大小 for(int i=L;i<=R;i++) { if(i%2==0) rst1+=pow(i,2); else rst2+=pow(i,3); } printf("%lld %lld\n",rst1,rst2); }}

 

int min=INT_MAX;//定义最大能表示的数bool cmp(int a,int b){    return abs(a)>abs(b)?true:false;//返回由大到小的数组排序 }    sort(arr,arr+n,cmp);//按照绝对值由大到小排序

 

hdoj_2022

#include
#include
#include
#include
#include
#include
using namespace std;int arr[2000][2000];int main(){ int m,n; while(scanf("%d %d",&m,&n)!=EOF) { //int arr[2000][2000]; int arr[2000][2000]就退出,这么大居然不用new/malloc。 //函数体内的数组会放在栈中,一般会爆。不过还是推荐使用malloc/calloc把数组放在堆上或者开全局 //全局变量存在于静态区,这样就没有爆栈的问题了。 int rst=0; int position_x=0,position_y=0; for(int i=0;i

 

hdoj_2023

#include
#include
#include
#include
#include
#include
using namespace std;int arr[51][6];int main(){ int n,m; while(scanf("%d %d",&n,&m)!=EOF) { int rst=0; double sub_score[6]; double stu_score[51]; memset(sub_score,0.0,sizeof(sub_score));//必须是include
中 memset(stu_score,0.0,sizeof(stu_score)); for(int i=0;i

 

 

hdoj_2024

#include
#include
#include
#include
#include
#include
using namespace std;int main(){ /* gets(str);//gets只能是char数组不能是string类型。gets(string)是错误的 puts(str); "ff ai_2"含有空格的也可以正常读入(for也可以) */ int n; while(scanf("%d",&n)!=EOF) { //getchar();//注意如果没有getchar()的话\n会被计入str //cout<
='A'&& str[i]<='Z') || (str[i]<='z' && str[i]>='a') || str[i]=='_' )) { printf("no\n"); tag=false; break; } if(i!=0 && !( (str[i]>='A'&& str[i]<='Z') || (str[i]<='z' && str[i]>='a') || str[i]=='_' || (str[i]<='9'&&str[i]>='0'))) { tag=false; printf("no\n"); break; } } if(tag) printf("yes\n"); } } return 0; }

 

 

hdoj_2030

 

#include
#include
#include
#include
#include
#include
using namespace std;/*汉字编码方式很多,有国标码(GB2312_1980),大五码,GBK,简体18030,区位码,电报码,还有它们的变形:unicode 大端小端码,UTF-8,UTF-*,HZ 等等。内码特点 :二进制双字节,每字节用到8bits.输入原理,把连续输入的ASCII字符串,通过中文输入软件转化为双字节 中文内码。在C语言中,可以通过将汉字作为字符串输入。由于一个汉字占2个字节,所以对汉字的操作,只能以2个字节作为操作单位。下面通过具体实例来说明汉字在C语言中的使用:char s[] = "首都北京"; // 将汉字字符赋值给字符数组char s2[20]; // 定义字符数组,存放用户输入的汉字scanf("%s", s2); // 接收用户输入的汉字字符printf("%d\n", sizeof(s)); // 计算字符数组s所占的内存单元,输出9(最后一个字节是结束字符'\0')printf("%s\n", &s[2]); // 输出“都北京”(首字占2个字节)printf("%s\n", s2); // 输出用户输入的汉字 **********关键是:汉字的ascii码是小于0的 */ int main(){ int n; while(scanf("%d",&n)!=EOF) { getchar(); while(n--) { int rst=0; char str[1000]; gets(str); for(int i=0;str[i]!='\0';i++) if(str[i]<0) rst++; rst=rst/2; printf("%d\n",rst); } } return 0; }

 

转载于:https://www.cnblogs.com/zmmz/p/10007416.html

你可能感兴趣的文章
正则表达式中的捕获和反向引用笔记
查看>>
循环嵌套输出一个4行5列的星星*图案
查看>>
认识IO(输入输出流)
查看>>
springcloud在 repository层通过sql语句实现查询功能
查看>>
BZOJ2322: [BeiJing2011]梦想封印
查看>>
[转]差分约束系统详解
查看>>
[POJ1185]炮兵阵地(状压DP)
查看>>
Redhat5.9安装qt5.5.1出错error while loading shared libraries:libX11-cxb.so.1 ...
查看>>
这是否为复制Bug?求解!
查看>>
UIImageview的简单运用
查看>>
GC算法
查看>>
求质数——埃拉托色筛选法
查看>>
js遍历json对象,双json数组对比
查看>>
JStorm之Topology调度
查看>>
SAR ADC : 逐次逼近寄存器型(SAR)模数转换器(ADC)
查看>>
JSP九大内置对象
查看>>
github发布静态页面
查看>>
python~~~~lambda表达式、递归~~~
查看>>
Winform
查看>>
配置IIS 7 时遇到的一些问题
查看>>