代码改变世界

A+B for Input-Output Practice (III) ACM

2013-12-01 15:41 by XF邪神, 350 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述Your task is to Calculate a + b.输入Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.输出For each pair of input integers a and b you should 阅读全文

C/C++经典程序训练5---图形打印问题 SDUT ACM

2013-11-30 21:13 by XF邪神, 743 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述图形的规则如下 ,要求输入n的值,按照图形的打印规则打印出相关的图形:输入输入整数n。输出按图形的规律打印出相关的图形。示例输入4示例输出 + +*+ +***++*****+ +***+ +*+ +#include int main(){ int n, i, j; scanf("%d", &n); for (i=1; i<=n-1; i++) printf(" "); printf("+\n"); for (i=2; i<n*2-1; i++){ if (i <= n){ for (j=1; j&l 阅读全文

C/C++经典程序训练3---模拟计算器 SDUT ACM

2013-11-30 21:11 by XF邪神, 1754 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述简单计算器模拟:输入两个整数和一个运算符,输出运算结果。输入第一行输入两个整数,用空格分开;第二行输入一个运算符(+、-、*、/)。输出输出对两个数运算后的结果。示例输入30 50*示例输出1500#include int main(){int a, b;char c;scanf("%d %d\n%c", &a, &b, &c); switch (c){ case '+': printf("%d\n", a + b); break; case '-': printf("%d\n&q 阅读全文

C/C++经典程序训练2---斐波那契数列 SDUT ACM

2013-11-30 21:10 by XF邪神, 980 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述编写计算斐波那契(Fibonacci)数列的第n项函数fib(n)(n=3)。输入输入整数n的值。输出输出fib(n)的值。示例输入7示例输出13#include int main(void){ int f1=1, f2=1, f3;int i, n;scanf("%d", &n);if(n<=2)printf("%d\n", f1);else{for(i=3;i<=n;i++){f3=f1+f2;f1=f2;f2=f3;}printf("%d\n", f3);}} 阅读全文

C/C++经典程序训练1---最大公约数与最小公倍数 SDUT ACM

2013-11-30 21:07 by XF邪神, 748 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述输入两个整数,求它们的最大公约数与最小公倍数。输入输入两个整数,两个整数之间用空格分开。输出第一行输出最大公约数;第二行输出最小公倍数。示例输入6448示例输出16192#include int main(void){int m, n, r, t, a, b;scanf("%d %d", &m, &n); a = m ;b = n ;if ( m < n ){t=m ; m=t ; n=t ;}while ( n != 0 ){r = m % n ; m = n ; n = r ;}printf("%d\n%d\n", m, 阅读全文

No Brainer sdut acm

2013-11-30 21:05 by XF邪神, 313 阅读, 0 推荐, 收藏, 编辑
摘要:题目描述Zombies love to eat brains. Yum.输入The first line contains a single integer n indicating the number of data sets. The following n lines each represent a data set. Each data set will be formatted according to the following description:A single data set consists of a line "X Y", where X i 阅读全文

A+B for Input-Output Practice (II)

2013-10-31 21:56 by XF邪神, 295 阅读, 0 推荐, 收藏, 编辑
摘要:#include int main(void) { int a,b; while(scanf("%d %d",&a,&b)!=EOF) printf("%d\n",a+b); return 0; } 阅读全文