acm_hdu ACM Steps Section1(1.1.1-1.1.8)

1.1.1

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

int main(int argc, const char * argv[])
{
int a,b;
while (scanf("%d%d",&a,&b) != EOF)
{
printf("%d\n",a+b);
}
return 0;
}

1.1.2

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

int main(int argc, const char * argv[])
{
int n = 0;
n = scanf("%d",&n);

int a,b = 0;
//int *res = (int *)malloc(n);

for (int i = 0;i < n && scanf("%d%d",&a,&b) != EOF;i++)
{
//res[i] = a+b;
printf("%d",a+b);
}

//for (int i = 0;i < n;i++)
//printf("%d\n",res[i]);

return 0;
}

1.1.3

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

int main(int argc, const char * argv[])
{
int a,b = 0;
while (scanf("%d%d",&a,&b) != EOF && scanf("%d",&a) != 0 && scanf("%d",&b) != 0)
{
printf("%d",a+b);
}
return 0;
}

1.1.4

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

int main(int argc, const char * argv[])
{
while (scanf("%d",&n) != EOF)
{
if (n == 0)
exit(0);

int sum = 0;
for (int i=0;i<n;i++)
{
int a = 0;
scanf("%d",&a);
sum += a;
}
printf("%d\n",sum );

}
return 0;
}

1.1.5

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

int main(int argc, const char * argv[])
{
int n1 = 0;
while (scanf("%d",&n1) != EOF)
{
for (int i = 0;i < n1;i++)
{
int n2 = 0;
scanf("%d",&n2);

int sum = 0;
for (int j = 0;j < n2;j++)
{
int a = 0;
scanf("%d",&a);
sum += a;
}
printf("%d\n",sum);
}
}
return 0;
}

1.1.6

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

int main(int argc, const char * argv[])
{
int n = 0;
while (scanf("%d",&n) != EOF)
{
for (int i = 0;i < n;i++)
{
int sum = 0;
for (int i = 0;i < n;i++)
{
int a = 0;
scanf("%d",&a);
sum += a;
}
printf("%d\n",sum);
}
}
return 0;
}

1.1.7

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

int main(int argc, const char * argv[])
{
int a,b = 0;
while (scanf("%d%d",&a,&b) != EOF)
{
printf("%d\n\n",a+b);
}
return 0;
}

1.1.8

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

int main(int argc, const char * argv[])
{
int n1 = 0;
while (scanf("%d",&n1) != EOF)
{
for (int i = 0;i < n1;i++)
{
int n2 = 0;
scanf("%d",&n2);

int sum = 0;
for (int j = 0;j < n2;j++)
{
int a = 0;
scanf("%d",&a);
sum += a;
}
(i<n1-1)?printf("%d\n\n",sum):printf("%d\n",sum);
//最后一次输出不要有空行!
}
}
return 0;
}

时间: 2024-11-17 23:54:56

acm_hdu ACM Steps Section1(1.1.1-1.1.8)的相关文章

acm_hdu ACM Steps Section2(1.2.1-1.2.8)

1.2.1 #include <stdio.h>#include <stdlib.h> #define up 6#define down 4#define stop 5 int main(int argc, const char * argv[]){ int n = 0; while (scanf("%d",&n) != EOF) { if (n == 0) exit(0); int current = 0; int next = 0; int sum

acm steps

1.1 根蒂根基输入输出:LCY的 A+B 8题 (1089~1096) 1.2 C说话根蒂根基:根蒂根基入门题 (2104,2088,1076,2095,1061,1170,3361,1197) 1.3 排序,贪婪: 1052 很恶心的一道贪婪题 3177 我推荐的这题貌似卡了不少人,遵守差值排序 (1236,1084,2093,2111,2187,1157) 2.1 简单数学题:GCD和素数生成占了很大一项目组 1071 积分题 1717 这题斗劲麻烦 (1108,2138,2504,121

hdu ACM Steps 1.2.8 Balloon Comes!

水题 #include<cstdio> char s[10]; int T,a,b,res; int main() { scanf("%d",&T); while(T--) { scanf("%s%d%d",s,&a,&b); switch (s[0]) { case '+' : printf("%d\n",a+b); break; case '-' : printf("%d\n",a-b)

hdu ACM Steps 1.3.1 第二小整数

水题. 我还以为是快速选择,但快排直接就过了. #include<cstdio> #include<algorithm> using namespace std; const int maxn = 500000 + 10; int a[maxn]; int T,n; int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); for(int i=1;i<=n;i++

hdu ACM Steps 1.2.5 find your present (2)

基础题.异或. 这道题很简单.但一开始我并没有想到O(n)的算法,然后排序tle了一发. 后来一直在想怎么使得俩个相同数互相"抵消"掉,灵机一动,发现这是异或. #include<cstdio> #include<algorithm> using namespace std; const int maxn = 100000 + 10; int a,n,ans; int main() { while(scanf("%d",&n) &am

hdu ACM Steps 1.2.4 Box of Bricks

模拟题. 题意为把高度不同的砖头堆变成高度相同的砖头堆最少需要移动几次. 想想就知道,要把每个砖头堆变成平均高度砖头堆最少需要移动的块数就是俩者的差值. 把所有差值都加起来以后要除以2,因为移动一块砖头对俩个砖头堆有影响. #include<cstdio> #include<cmath> const int maxn = 100 + 10; int a[maxn],n,s,h,ans,kase; int main() { while(scanf("%d",&am

hdu ACM Steps 1.2.3 A+B Coming

模拟题. 16进制转化为10进制相加.toupper函数为小写转换为大写,isalpha函数判断是否为字母. #include<cstdio> #include<cstring> #include<cctype> using namespace std; const int maxn = 100 + 10; const int base = 16; char s[5][maxn]; int a,b; int trans(int m) { int ans=0,n=strl

最左/右边的数-hd1060/1061

左边: http://acm.hdu.edu.cn/showproblem.php?pid=1060 1 #include <iostream> 2 #include <math.h> 3 using namespace std; 4 5 int main() 6 { 7 int n,m,d,i; 8 double l; 9 while(cin>>n) 10 11 { 12 for(i=1;i<=n;i++) 13 { 14 cin>>m; 15 l=

HDU1219--AC Me

AC Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11549    Accepted Submission(s): 5123 Problem Description Ignatius is doing his homework now. The teacher gives him some articles and asks