信息学奥赛一本通(C++版)

2018年信息学奥赛NOIP资料下载
信息学奥赛一本通(C++版) 第一部分 C++语言
第一章 C++语言入门

//1000 入门测试题目
#include <stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
return 0;
}

//1001 Hello,World!
#include <stdio.h>
int main(){
printf(“Hello,World!”);
return 0;
}

//1002 输出第二个整数
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%d",b);
return 0;
}

//1003 对齐输出
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%8d %8d %8d",a,b,c);
return 0;
}

//1004 字符三角形
#include <stdio.h>
int main(){
char s[2];
scanf("%s",s);
printf(" %c \n %c%c%c \n%c%c%c%c%c",s[0],s[0],s[0],s[0],s[0],s[0],s[0],s[0],s[0]);
return 0;
}

//1005 地球人口承载力估计
//基本思路,每年的再生资源刚好被消耗,现有资源不消耗,才能可持续发展
//c+da=xa
//c+db=yb
//d*(b-a)=yb-xa
//d=(yb-xa)/(b-a)
#include <stdio.h>
int main(){
int x,a,y,b;
scanf("%d%d%d%d",&x,&a,&y,&b);
printf("%.2f",(yb-xa)*1.0/(b-a));
return 0;
}

猜你喜欢

转载自blog.csdn.net/tianli315/article/details/85063561