1:代码如下: // 3.10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include <iomanip> using namespace std; void main() { cout<<"输入一个A-D范围内的大写字母作为成绩评价"<<endl; char iInput; cin >> iInput; switch…
1:代码如下: // 3.12.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入一个A-D范围内的大写字母作为成绩评价"<<endl; char iInput; cin >> iInput; if(iInput == 'A') { cout <&l…
1:代码如下: // 3.11.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"输入一个A-D范围内的大写字母作为成绩评价"<<endl; int iInput; cin >> iInput; if(iInput = 'A') { cout <<…
1:代码如下: // 3.1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using namespace std; void main() { int iInput; cout << "输入一个整数" << endl; cin >> iInput; //输入一整型数 !=) cout << "这个整数是奇数&quo…
1:为字符串数组赋值的方式有两种,即数组元素逐一赋值和使用聚合方式赋值. 为数组元素逐一赋值.例如: pWord[0]='H'; 使用聚合方式赋值如: char pWord[]={'H','E','L','L','O'}; 2:字符数组的一些说明 (1)聚合方式只能在数组声明的时候使用 char pWord[5]; pWord={'H','E','L','L','O'};//错误 (2)字符数组不能给字符数组赋值 char a[5]={'H','E','L','L','O'}; char b[5…
1:代码如下: // 2.10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using namespace std; void main() { ; double y=-3.1415; cout << "x="; cout.width();//输出字符串的宽度为10 cout << x; cout << "y=";…
1:代码如下: // 2.3.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" int main() { ; /*定义长整型变量,为其赋值*/ printf("the Long is %ld\n",iLong); /*输出长整型变量*/ printf("the string is: %s\n","LOVE"); /*输出字符串*/ printf("the string is: %…
1:代码如下: // 2.5.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" int main() { long iLong; /*长整型变量*/ short iShort; /*短整型变量*/ ; /*整型变量,为其赋值为1*/ ; /*整型变量,为其赋值为2*/ ]; /*定义字符数组变量*/ printf("Enter the long integer\n"); /*输出信息提示*/ scanf("%ld&qu…
1:puts函数可以输出提示信息的字符串. 2:代码如下: // 2.4.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" int main() { int iInt1,iInt2; /*定义两个整型变量*/ puts("请输入两个数字"); /*通过puts函数输出提示信息的字符串*/ scanf("%d%d",&iInt1,&iInt2); /*通过scanf函数得到输入的数据*/ pri…
1:代码如下: // 3.18.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using namespace std; void main() { ; int i; ;i<=;i++) //for循环语句 sum+=i; cout << "数字1-10的和:" << sum << endl; } 运行结果:…