C/C++初学者 - 语法题库

首页    重新查询   

一星为基础题,五星为工业应用题;星级越高,难度越大;不一定要做完所有题,差不多就可以进入下一章,反复迭代
共 18 条结果 ( 每页 10条 )
 
章节: 第1章 C++语言入门
难度: ★ 1
题目:
输出语句
描述:
#include<iostream>
using namespace std;
int main()
{
  int my=13-3;
  cout<<my<<endl;
  my=my*3; 
  cout<<my<<endl;
  return 0;
}
  

    
  
10
30

章节: 第1章 C++语言入门
难度: ★ 1
题目:
输出语句
描述:
#include<iostream>
using namespace std;
int main()
{
  int a,n,i;
  a=n+19;
  n=n+4; 
  cout<<"a="<<a<<" n="<<n<<endl;
  return 0;
}
  
由于未赋值,结果不确定
  
a=4233873 n=4233858 [答案不唯一]

章节: 第1章 C++语言入门
难度: ★ 1
题目:
输出语句
描述:
#include<iostream>
using namespace std;
int main()
{
  int a=4+56;
  char b='m';
  cout<<a<<b<<endl;
  return 0;
}
输出:_______________________
  

    
  
60m

章节: 第1章 C++语言入门
难度: ★ 1
题目:
输出语句
描述:
#include<iostream>
using namespace std;
int main()
{
  float a,b;
  b=15;
  a=b+13;
  cout<<a;
  cout<<"b+a="<<b+a;  
  return 0;
}
输出:______________________
  

    
  
28b+a=43

章节: 第1章 C++语言入门
难度: ★ 1
题目:
编程输入a、b的值,交换a、b的值后输出。
描述:
例:输入:6  3  
          输出:a=3 , b=6
写出程序:
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	___________;
	___________;
	cout ___________;
return 0;
}
  

    
  
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a;a=b;b=c;
	cout<<"a="<<a<<",b="<<b;
return 0;
}

章节: 第1章 C++语言入门
难度: ★ 1
题目:
输入长方形的长、宽a和b,输出长方形的周长、面积c和s,写一程序完成。
描述:
例:输入:4  9
          输出:c=26 ,s=36
写出程序:
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,s;
	___________;
	___________;
	___________;
	cout ___________;
return 0;
}
  

    
  
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,s;
	cin>>a>>b;
	c=(a+b)*2;
	s=a*b;
	cout<<"c="<<c<<" ,s="<<s;
return 0;
}

章节: 第1章 C++语言入门
难度: ★ 1
题目:
编一程序,键盘输入整数a,b的值,然后打印a除以b的商的整数部分m及余数n。
描述:
 例:输入:8  3
     输出:m=2  n=2
写出程序:
#include<iostream>
using namespace std;
int main()
{
	int a,b,m,n;
	___________;
	___________;
	___________;
	cout ___________;
return 0;
}
  

    
  
#include<iostream>
using namespace std;
int main()
{
	int a,b,m,n;
	cin>>a>>b;
	m=a/b;
	n=a%b;
	cout<<"m="<<m<<"  n="<<n;
return 0;
}

章节: 第1章 C++语言入门
难度: ★ 1
题目:
FOR语句转化为while 语句
描述:
#include <iostream>
using namespace std;
int main()
{
	int a=0,b=0;
	for (int i=1; i<=5; i++)
	{
		a=a+i;
		b=b+a;
	}
	cout<<b<<endl;	
	return 0;
}
//=================
#include <iostream>
using namespace std;
int main()
{
	int a=0,b=0,i=0;
	while (________)
	{
		________;
		a=a+i;
		________;
	}
	cout<<b<<endl;	
	return 0;
}
  

    
  
#include <iostream>
using namespace std;
int main()
{
	int a=0,b=0,i=0;
	while (i<5)
	{
		i++;
		a=a+i;
		b=b+a;
	}
	cout<<b<<endl;	
	return 0;
}