1 / 3
文档名称:

C上机实验报告.docx

格式:docx   大小:31KB   页数:3页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

C上机实验报告.docx

上传人:dajiede 2022/8/20 文件大小:31 KB

下载得到文件列表

C上机实验报告.docx

相关文档

文档介绍

文档介绍:C语言上机实验其开发环境的选择也很重要,虽说名称上是一样,但网上下的还是有很多的版本,有的
下下来就不能正常运行, 有的不管怎样都会出现erros (即使是和书上的
一模一样),经过几经尝试终于找到了一个相对其他来说比较正常的 TC。
C语言上机实验其开发环境的选择也很重要,虽说名称上是一样,但网上下的还是有很多的版本,有的
下下来就不能正常运行, 有的不管怎样都会出现erros (即使是和书上的
一模一样),经过几经尝试终于找到了一个相对其他来说比较正常的 TC。
应用scanf输入数据时,应在同样的位置上输入同样的字符。
#in clude<> void mai n(void) (
int *p1,*p2,*p,a,b;
prin tf("please en ter two in teger nu mbers:\n");
scan f("%d,%d",&a,&b);
p 仁&a;
p2=&b;
if(a<b)
(
p=p1;
p 仁 p2;
p2=p;
}
prin tf("a=%d,b=%d\n",a,b);
prin tf("max=%d,mi n=%d\in",*p1,*p2);
}
如上,如果输入数据5 9,运行是就会出错。因为在“ scanf("%d,%d",&a,&b); ”中字符是 气”, 不是空格。
错误结果:
please enter tuo integer numbeirE: 5 9
a=5,b=4200326
nax-4200326,nin=5
rocess returne
;> execut ion t i<nc : 3 -953 g Press any hey to continue.
E确结果:
please EFI ter tuo integer numbers:
5,9
a=5,b=9
nax=9 ,min =5
rocess returnee
execution t ime
ress any to continue.
,int a【i】与数组中元素a【i】的“ i ”的范围的区别。如
下程序:
#i nclude<>
#defi ne N 7
void mai n()
{
int a[N]={20,10,90,59,60,80,70};
int i,j;
for(i=0; i<N-1-i ;i++)
{
j=a[i];
a[i]=
a[N-i-1];
a[N-i-1] =j;
}
for(i=0;i<N;i++)
prin tf("%3d",a[i]);
}
70 60 59 ¥0 13 2&
returned 3 execution tine : s
any kev to cant inue
如果将上面程序中的红色部分的 N-1-i改成N-i,在程序运行时就会出错
如:
#i nclude<>
#defi ne N 7
void mai n()
{
int a[N]={20,10,90,59,60,80,70};
int i,j;
for(i=0 ;i<N-i; i++)
{
j=a[i];