发布于2025-01-19 阅读(0)
扫一扫,手机访问
#include
#include
long fun (long num)
{long k=1; //这里缺少语句结束符分号
do
{ k*=num%10 ;
num/=10; //运算符是 /= 不是 \=
}while(!num); //这里缺少 do ……while 语句结束符分号
return (k) ;}
main( )
{ long n ;
printf("\n Please enter a number:") ;/*想换行使用\n 否则去掉斜线*/
scanf("%d",&n);
printf("\n%ld\n", fun(n)) ;
system("pause");
}
通过啦
改错题:
//后面是改错后的答案
1. x=5b+3a-10;
//x=5*b+3*a-10;
2. int *p,a;*p=&a;
//*p=a;
3. int x; y; z;
//int x,y,z;
4. for (i<=n;i=0;i++) n=n+1;
//for (i=0;i<=n;i++) n=n+1;
5. int a=b=c=0;
//int a=0,b=0,c=0;
6. if x>=y x++ else y++;
//if(x>=y)x++; else y++;
7. int a[5]={3,2,56,,8,9};
//int a[5]={3,2,56,8,9};
8. if (0<x<10) y=x+1;
//if ((x>0)&&(x<10)) y=x+1;
9. int a[10],i;for(i=0;i<=9;i++); scanf("%d",a[i]);
//int a[10],i;for(i=0;i<=9;i++) scanf("%d",a[i]);
10. for(s=0;i=1;i<=10;i++); s+=i;
//for(s=0;i=1;i<=10;i++) s+=i;
11. #define PI*r*r
//#define XXX PI*r*r(这个应该是有一个define的对象的,暂定叫XXX吧)
12. char str="string";
//char *str="string";
13. void f1(void) { int x=3;… return x}
//int f1(void) { int x=3; return x;}
14. int a; *p=a;
//int a; int *p=a;
15. char name[20]; scanf("%s",&name);
//char name[20]; scanf("%s",name);
public class test {
static string a = "10";
static int b = 20, c = 0, d;
public static void main(string[] args) {
try {
d = integer.parseint(a);
if (b == 20)
throw (new yourexception("特殊错误"));
d = b / c;
} catch (numberformatexception e) {
system.out.println("数据格式错误");
} catch (yourexception e) {
system.out.println(e.getexceptionmessage());
} catch (arithmeticexception e) {
system.out.println("算术运算错误");
}
}
}
class yourexception extends exception {
private string exceptionmessage;
public yourexception(string s) {
exceptionmessage = s;
}
public string getexceptionmessage() {
return exceptionmessage;
}
}
错误一:
throws(yourexception("特殊错误"));
改成
throw (new yourexception("特殊错误"));
错误二:
catch(exception e){
system.out.println(e.getexceptionmessage());
}
改成
catch (yourexception e) {
system.out.println(e.getexceptionmessage());
}
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店