我有个问题.我写了这段代码,ahac和main.c:
档案:啊
#ifndef _a_H
#define _a_H
int poly (int a, int b, int c, int x);
int square (int x)
{
return x*x;
}
#endif // _a_H
Run Code Online (Sandbox Code Playgroud)
档案:ac
#include "a.h"
int poly (int a, int b, int c, int x)
{
return a*square(x) + b * x +c;
}
Run Code Online (Sandbox Code Playgroud)
file:main.c
#include <stdio.h>
#include "a.h"
int main()
{
int p1 = poly1 (1 ,2 , 1, 5);
int p2 = poly2 (1 ,1 , 3, 5);
printf ("p1 = %d, p2 …
Run Code Online (Sandbox Code Playgroud) 创建一个自定义异常是一个好主意,当应用程序逻辑失败时会抛出这个异常,而这个异常会被处理掉吗?
我想,最好还是返回一个对象或一个值; 但:
如果没有,那么在我们的代码中引入一些自定义异常的正确条件是什么?
谢谢!
我是编程的新手,也是这个网站的新手,所以你好......我试图获得10到10之间整数的运行总数,但是我得到了胡言乱语的答案,我只是无法理解为什么.为了试图找出问题所在,我补充说
printf(" running total is %d\n", sum);
Run Code Online (Sandbox Code Playgroud)
线路到while循环,但只是得到了更多相同的废话...请参阅http://codepad.org/UxEw6pFU的结果....
我确信这有一个非常明显的解决方案......我只是太傻了看不过它!有谁知道我做错了什么?
#include <stdio.h>
int main(void) {
int count,sum,square;
int upto=10;
count = 0;
square = 0;
while (++count < upto) {
square = count * count;
printf("square of %d is %d",count,square);
sum =square + sum;
printf(" running total is %d\n", sum);
}
printf("overall total of squares of integers 1 thru 10 is %d\n", sum);
return 0;
}
Run Code Online (Sandbox Code Playgroud)