Pascal与c的对照

Pascal与c的对照
语法	pascal	c
区分字母大小写	不区分	区分
模块,复合语句	begin...end;	C语言是{...}
逻辑符	and  or   not	&&   ||    !
赋值	x:=5;	x=5;
比较符	> ,  < ,  = ,  >=,  <=,  <>	> ,  < ,  = = ,  >=,  <=,  !=
运算符	+, -, *, div, mod	+, -, *, /, %
常用类型	Integer;
Longint;
Int64;
Real;
Double;
Extended;
Boolean;	

Int;
Long;
Long long;
Float;
Double;
Long double;
没有。(0为假,1为真)
变量说明	Var a,b:integer;	Int a,b;
I:=i+1;	Inc(i);	I++;
I:=i-1;	Dec(i);	i--;
输入语句	Read(a,b);	scanf(“%d%d”,&a,&b);
输出语句	Write(a,b);
Writeln(a,b);	printf(“%d%d”,a,b);
printf(“%d%d\n”,a,b);
条件语句 1	If x=5 then 
  Begin a:=1; b:=2 end;	if (x= =5)
  { a=1;b=2;}
条件语句2	If x=5 then 
  Begin a:=1; b:=2 end
Else
  Begin c:=4;d:=5 end;	if (x= =5)
  { a=1;b=2;}
else
  {c=3;d=5}
条件语句3	If x=5 then begin …end
Else if x=4 then begin …end
Else if x=3 then begin …end
Else if x=2 then begin …end
Else begin … end;	if(x= =5){ ..}
else if (x= =4) { …}
else if (x= =3) { …}
else if (x= =2) { …}
else {…}
开关语句	Case ch of
‘a’,’b’: 语句1;
‘c’: 语句2;
‘d’,’e’,’f’: 语句3;
… …
  Else语句n;
End;	Switch(ch)
{  case ‘a’:语句1;break;
   case ‘b’:语句2;语句3;break;
   case ‘c’:语句4;break;
   … …
   defale: 语句n;
}
循环语句1	For i:=1 to 10 do
  Begin  …   end;
For i:=10 down to 1 do
  Begin … end;	for(i=1;i<=10;i++)
  { … }
for(i=10;i>=1;i--)
  { … }
循环语句2	While x>5 do
  Begin  …   end;	while(x>5)
   { … }
循环语句3	Repeat
  …
Until x<0;	do
 { … }
while(x>=0);
跳转	Break;
Continue;
Halt;	Break; 提前结束循环
Continue;本次循环跳过
没有?
数组说明	Val  a:array[0..100] of longint;
    B:array[0..10,0..10] of integer;	Long a[101];
Int a[11][11];
字符数组	Var a:array[0..10] of char;	Char a[11];
		
		
文件读入写出	Assign(input,’aaa.in’);reset(inpu);
Assign(outout,’aaa.out’);rewrite(output);

Close(input);close(output);	Freopen(“aaa.in”,”r”,stdin);
Freopen(“aaa.out”,”w”,stdout);

转载于:https://www.cnblogs.com/yzzd/archive/2011/11/27/2265661.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值