c,c++,java,php,python,javascript,go,lua语言差异

一、注释

注释类型cc++javaphppythonjavascriptgolua
单行注释/**///////、##//////
多行注释/**//**//**//**/‘’’ ‘’’、""" “”"/**//**//**/

二、关键字

	c的关键字:
		auto、double、int、struct、breakelse、long、switchcaseenum、register、typedef、char、extern、
		union、returnconst、float、short、unsigned、continuefor、signed、voiddefault、goto、sizeof、
		volatile、dowhilestaticif
	------------------------------------------------------------------------------------------------------------
	c++的关键字:
		auto、bool、breakcasecatch、char、classconstcontinuedefaultdelete、dllexport、do、double、
		else、cnum、explicit、extern、false、float、for、friend、goto、if、inline、int、long、main、mutable、
		naked、namespace、new、noreturn、operator、privateprotectedpublic、register、return、short、signed、
		sizeof、static、struct、switch、template、this、thread、throwtruetry、typedef、typeid、typename、
		union、unsigned、uuid、virtual、void、volatile、wmain、while------------------------------------------------------------------------------------------------------------	
	php的关键字:
	
	------------------------------------------------------------------------------------------------------------
	python的关键字:
		acos、and、array、asin、assert、atan、breakclass、close、continue、cos、Data、def、del、e、elif、else、except、
		exec、exp、fabs、float、finally、floor、forfrom、global、ifimportin、input、int、is、lambda、log、log10、not、
		open、or、pass、pi、print、raise、range、return、sin、sqrt、tan、try、type、while、write、zeros
	------------------------------------------------------------------------------------------------------------	
					

三、输出Hello World

	1.c
		#include <stdio.h>
		int main(int argc, char *argv[]) {
			printf("Hello World\n");
			return 0;
		}
	------------------------------------------------------------------------------------------------------------	
	2.c++
		#include <iostream>
		int main(int argc, char** argv) {
			printf("Helllo world\n");
			return 0;
		}
	------------------------------------------------------------------------------------------------------------	
	3.java
		package com.helloworld
		public class HelloWorld(
			public static void main(String[] args){
				System.print("Hello World");
			}
		)
	------------------------------------------------------------------------------------------------------------	
	4.php
		<?php
			echo "Hello World";
		?>
	------------------------------------------------------------------------------------------------------------		
	5.python
		print("Hello World")
	------------------------------------------------------------------------------------------------------------	
	6.javascript
		document.write("Hello world");
	------------------------------------------------------------------------------------------------------------	
	7.go
		package main
		import(
			"fmt"
		)
		func main(){
			fmt.Println("Hello World")
		}
	------------------------------------------------------------------------------------------------------------	
	8.lua
		print("Hello World")

四、数据类型

数据类型数量
c整型字符型浮点型枚举型数组类型结构体类型共用体类型指针类型空类型布尔类型
c++整型字符型浮点型枚举型数组类型结构体类型共用体类型指针类型引用类型布尔类型
java
phpboolean(布尔型)integer(整型)float(浮点型) / double(双精度型)string(字符型)array(数组)object(对象)resource(资源)NULL(空)
pythonNumbers(数字)String (字符串)Tuple(元组)List(列表)Dictionary(字典)Set(集合)
javascript
go
lua

示例

	c
		1.有符号基本整型 (-2147483648 ~ 2147483648)
			int iNumber;
			iNumber=10;
		2.无符号基本整型 (0 ~ 4294967295)
			unsigned iNumber;
			iNumber=10;
		3.有符号短整型 (-32768 ~ 32767)
			short iNmuber;
			iNumber=10;
		4.无符号短整型 (0 ~ 65535)
			unsigned short iNumber;				
			iNumber=10;
		5.有符号长整型 (-2147483648 ~ 2147483648)
			long iNumber;
			iNumber=10;
		6.无符号长整型 (0 ~ 4294967295)
			unsigned long iNumber;
			iNumber=10;
		7.单精度类型 (-3.4 * 10-38次幂 ~ 3.4 * 1038次幂)
			float fNumber;
			fNumber=3.14f;
		8.双精度类型 (-1.7 * 10-308次幂 ~ 1.7 * 10308次幂)
			double fNumber;
			fNumber=3.141;
		9.长双精度类型 (-1.7 * 10-308次幂 ~ 1.7 * 10308次幂)
			long double fNumber;
			fNumber=3.141;
		10.字符类型 (-128 ~ 127)
			char cChar;
			cChar='a';
		11.无符号字符类型 (0 ~ 255)
			unsigned char cChar;
			cChar='a';
	------------------------------------------------------------------------------------------------------------		    
	c++
		1.有符号基本整型 (-2147483648 ~ 2147483648)
			int iNumber;
			iNumber=10;
		2.无符号基本整型 (0 ~ 4294967295)
			unsigned iNumber;
			iNumber=10;
		3.有符号短整型 (-32768 ~ 32767)
			short iNmuber;
			iNumber=10;
		4.无符号短整型 (0 ~ 65535)
			unsigned short iNumber;				
			iNumber=10;
		5.有符号长整型 (-2147483648 ~ 2147483648)
			long iNumber;
			iNumber=10;
		6.无符号长整型 (0 ~ 4294967295)
			unsigned long iNumber;
			iNumber=10;
		7.单精度类型 (-1.2 * 10-38次幂 ~ 3.4 * 1038次幂)
			float fNumber;
			fNumber=3.14f;
		8.双精度类型 (-2.2 * 10-308次幂 ~ 1.8 * 10308次幂)
			double fNumber;
			fNumber=3.141;
		9.长双精度类型 (-2.2 * 10-308次幂 ~ 1.8 * 10308次幂)
			long double fNumber;
			fNumber=3.141;
		10.字符类型 (-128 ~ 127)
			char cChar;
			cChar='a';
		11.无符号字符类型 (0 ~ 255)
			unsigned char cChar;
			cChar='a';
		12.布尔类型
			bool ret;
			ret = true;	
	------------------------------------------------------------------------------------------------------------
	java
	------------------------------------------------------------------------------------------------------------
	php
		1.布尔型
		$foo = True;
		2.整型
		$a = 1234;
		$a = -123;
		$a = 0123;
		$a = 0x1A;
		$a = 0b11111111;
		3.浮点型
		$f = 1.01;
		//*浮点型不能进行直接比较*
		4.字符串
		$str = '123';
		$str2 = "1234";
		5.数组
		$array = array(
			"fo1"=>"bar1",
			"fo2"=>"bar2",
		)
		6.对象
		calss foo{
			function do_foo(){
				echo "123";
			}
		}
		$bar = new foo;
		$bar->do_foo();
		7.资源
		$file = fopen('test.txt','r');
		8.NULL
		$a = NULL; 
	------------------------------------------------------------------------------------------------------------		
	python
		1.数字
		a = 38
		a = 3.14
		2.字符串
		a = "34"
		3.元祖
		tpl = (1,2,3,4)
		4.列表
		a_list = [1,2,3,4]
		5.字典
		keywords = {'1':1,'2':'2','3':3}
		6.集合
		a = {1,2,3,4}
	------------------------------------------------------------------------------------------------------------	
	javascript
	------------------------------------------------------------------------------------------------------------
	go
	------------------------------------------------------------------------------------------------------------
	lua

1、类型转换

	c
	------------------------------------------------------------------------------------------------------------
	c++
	    强制转换
		1.(int) x;
		2.int (x);
	------------------------------------------------------------------------------------------------------------
	java
	------------------------------------------------------------------------------------------------------------
	php
		1.转换为布尔型
		(bool)
		* 0, 0.0, "0", "", array(), 空对象, NULL 的返回值为false *
		2.转换为字符串
		(string)或strval()
		布尔型true转换为字符串返回“1”;
		布尔型flase转换为字符串返回“”;
		数组转换为字符串返回“Array”;
		资源转换为字符串返回“Resource id #1;
		NULL转换为字符串返回“”;
		3.转换为整数
		(int)或intval()
		布尔型true转换为整数返回1;
		布尔型flase转换为整数返回0;
		4.转换为浮点数
		(float)
		5.转换为数组
		(array)
		6.转换为对象
		(object)
		7.转换为Null
	    (unset)
	    8.转换为二进制字符串
	    (binary)
	    9.检测数据类型函数
	    is_bool(), is_string(), is_float(), is_double(), is_integer(), is_int(), is_null(), is_array(), is_object(), is_numeric()
	------------------------------------------------------------------------------------------------------------    		
	python
	------------------------------------------------------------------------------------------------------------
	javascript
	------------------------------------------------------------------------------------------------------------
	go
	------------------------------------------------------------------------------------------------------------
	lua

五、常用的转义字符

1.php
\a 响铃
\b 退格
\f 换页
\n 换行
\r 回车
\t 水平制表
\v 垂直制表
\ 反斜线
’ 单引号
‘’ 双引号
? 问号
\0 NULL
\ddd 1~3八进制字符
\xhh 1~2位16进制字符

六、变量和常量

变量和常量变量常量
cint iNumber=123#define PAI 3.14
c++int max=100const int MAX=100
java
php$a=1define(“CONTANT”,1)、const CONSTANT = 1
pythona=1b=2
javascript
go
lua

示例

	c
		变量存储类型
			自动 auto
			静态 static
			寄存器 register
			外部 extern
	------------------------------------------------------------------------------------------------------------
	c++
		变量存储类型
			自动 auto
			静态 static
			寄存器 register
			外部 extern
	------------------------------------------------------------------------------------------------------------													
	php
		

1、变量作用域

局部变量
全局变量

	php
		引用全局 global
静态变量
	php
		声明静态变量 static

七、 运算符

	c
		1.算术运算符(+-*/%2.赋值运算符(=+=-=*=/=3.字符串运算符( ..=4.位于算符(&|^~<<>>5.比较运算符(==!=<><=>=6.逻辑运算符(&&||!7.三元运算符 ex1 ? ex2 : ex3
		8.递增递减运算符 ++a,a++--a,a--
	------------------------------------------------------------------------------------------------------------
	c++
		1.算术运算符(+-*/%2.赋值运算符(=+=-=*=/=3.字符串运算符( ..=4.位于算符(&|^~<<>>5.比较运算符(==!=<><=>=6.逻辑运算符(&&||!7.三元运算符 ex1 ? ex2 : ex3
		8.递增递减运算符 ++a,a++--a,a--
	------------------------------------------------------------------------------------------------------------
	java
	------------------------------------------------------------------------------------------------------------
	php
		1.算术运算符(+-*/%2.赋值运算符(=.=+=-=*=/=3.字符串运算符( ..=4.位于算符(&|^~<<>>5.比较运算符(=====!=<>!==<><=>=<=>??6.逻辑运算符(and,&&,or,||,xor,!7.错误控制运算符 @
		8.三元运算符 ex1 ? ex2 : ex3
		9.递增递减运算符 ++$a,$a++--$a,$a--
	------------------------------------------------------------------------------------------------------------	
	python
		1.算术运算符(+-*/%//(整除),**(乘方))
		2.赋值运算符(=.=+=-=*=/=3.字符串运算符( ..=4.位于算符(&|^~<<>>5.比较运算符(==!=<><=>=6.逻辑运算符(and,or,not)
		7.三元运算符 ex1 ? ex2 : ex3
		8.递增递减运算符 ++a,a++--a,a--
	------------------------------------------------------------------------------------------------------------	
	javascript
	------------------------------------------------------------------------------------------------------------
	go
	------------------------------------------------------------------------------------------------------------
	lua 

1、运算符优先级

()> */ > ±

八、 流程与控制语句

	c
			1.if语句
				  if(expr){
					statement
				  }
			2.else语句
				  if(expr){
				  	statement1
				  }else{
				  	statement2
				  }
			3.elseif语句
				  if(expr){
				  	statement1
				  }else if(){
				  	statement3
				  }else{
				  	statement2
				  }
			 4.switch语句
			  		switch(expr){
						case value1:
							statement1
							break;
						case value2:
							statement2
							break;
						default:
							statementn;
							break;
					}
			5.while语句
					while(expr){
						statement
					}
			6.do-while语句
					do{
						statement
					}while(s);
			7.for语句
					for(i=1;i<10;i++){
						printf(i);
					}
			8.goto语句
						跳转指定位置语句
			9.breakcontinue
						常用于while,do-whilefor语句中
	------------------------------------------------------------------------------------------------------------										
	c++
			1.if语句
				  if(expr){
					statement
				  }
			2.else语句
				  if(expr){
				  	statement1
				  }else{
				  	statement2
				  }
			3.elseif语句
				  if(expr){
				  	statement1
				  }else if(){
				  	statement3
				  }else{
				  	statement2
				  }
			 4.switch语句
			  		switch(expr){
						case value1:
							statement1
							break;
						case value2:
							statement2
							break;
						default:
							statementn;
							break;
					}
			5.while语句
					while(expr){
						statement
					}
			6.do-while语句
					do{
						statement
					}while(s);
			7.for语句
					for(i=1;i<10;i++){
						printf(i);
					}
			8.goto语句
						跳转指定位置语句
			9.breakcontinue
						常用于while,do-whilefor语句中
	------------------------------------------------------------------------------------------------------------					
	java
	------------------------------------------------------------------------------------------------------------
	php
			1.if语句
				  if(expr){
					statement
				  }
			2.else语句
				  if(expr){
				  	statement1
				  }else{
				  	statement2
				  }
			3.elseif语句
				  if(expr){
				  	statement1
				  }else if(){
				  	statement3
				  }else{
				  	statement2
				  }
			 4.switch语句
			  		switch(expr){
						case value1:
							statement1
							break;
						case value2:
							statement2
							break;
						default:
							statementn;
							break;
					}
				5.while语句
					while(expr){
						statement
					}
				6.do-while语句
					do{
						statement
					}while(s);
				7.for语句
					for($i=1;$i<10;$i++){
						echo $i;
					}
				8.foreach语句
					foreach(array as $k=>$v){
					}
				9.breakcontinue
					常用于while,do-while,for和foreach语句中
				10.goto语句
					跳转指定位置语句
				11include和require语句
					include 引入失败会产生警告  include_once 只包含一次
					require 引入失败会产生致命错误 require_once 只包含一次
	------------------------------------------------------------------------------------------------------------				 					
	python
				1.if语句
				  if expr:
					statement
				2.else语句
				  if expr:
				  	statement1
				  else:
				  	statement2
				3.elseif语句
				  if expr:
				  	statement1
				  elif expr2:
				  	statement3
				  else:
				  	statement2
				 4.if/else单行
				 	maxnum = a if a>b else b
				 5.while语句
					while expr:
						statement
				 6.for语句
					for x in alist:
						print(x)
				 7.breakcontinue
				 		常用于while,for语句中
	------------------------------------------------------------------------------------------------------------			 			 	
	javascript
	------------------------------------------------------------------------------------------------------------
	go
	------------------------------------------------------------------------------------------------------------
	lua 

九、函数

	c
	------------------------------------------------------------------------------------------------------------
	c++
			1.函数定义
				int getNums(){
						return 10;
				}
				void message(){
						count << " Hello world " << endl;
				}
			2.名称空间
				namespace hello{
					int count=4;
						float getFloat(){
							return 3.14f;
						}
				}
				using namespace hello;
				hello::count;
				hello::getFloat();	
	------------------------------------------------------------------------------------------------------------
	java
	------------------------------------------------------------------------------------------------------------
	php
			1.函数定义
				function fun_name($arg1,&$arg2,...,$argn=0){
						$a=$arg1;
						return $a;
				}
			2.	可变函数
			    function f($arg=''){
			    		echo $arg;
			    }
			    $a = "f";
			    $a(1);
			4.	匿名函数
				function callback($back){
					echo $back();
				}
				$a=1;
				callback(function() use(&$a){
							echo $a;						
				})
	------------------------------------------------------------------------------------------------------------			
	python
			1.函数定义
				def addNumber(a,b):
					return a+b
			2.lambda表达式
				lambda a,b:a+b	
	------------------------------------------------------------------------------------------------------------			
	javascript
	------------------------------------------------------------------------------------------------------------
	go
	------------------------------------------------------------------------------------------------------------
	lua 

输入和输出

	c
		输入 scanf()
		输出 printf()
	------------------------------------------------------------------------------------------------------------
	c++
		输入 
			scanf()
			cin >> iInput 	
		输出 
			printf()
			cout << "hello world" << endl;	
	------------------------------------------------------------------------------------------------------------

操作字符串

操作日期和时间

会话处理

图像处理

文件处理

操作数据库

错误异常处理

------------------------------------------------------------------------------------------------------------
	c++
		try{
			throw 1;
		}catch(int error){
			cout << "error" << endl;
		}
		return 0;
	python
		try:
			a=1
		expect Exception as e:
			print(e)
------------------------------------------------------------------------------------------------------------			
				

socket

指针

指针变量 存储的是地值

	c
	c++
		int *p
		int a=100
		p=&a
		printf("%d",p)

面向对象

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值