应对大学C++综合作业及最后考试。
1. Write a function named strcpy, which copies the contents of string2 to string1.
void strcpy(char string1[[],char string2[])
{
int i=0;
while(string2[i]!=’\0’)
{
string1[i]=string2[i];
i++;
}
string1[i]=’\0’;
return;
}
2. Write a program which calculate sum of diagonal of a 3*3 matrix.(矩阵对角线)
main()
{
int a[3][3],sum=0;
int i,j;
printf(“Enter data:\n”);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf(“%d”,&a[i][j]);
for(i=0;i<3;i++)
sum=sum+a[i][i];
printf(“sum=%5d\n”,sum);
}
3. Input three integer numbers a,b and c with comma(逗号), then output them from small one to
big one.
#include <stdio.h>
main()
{
int t,a,b,c;
printf(" please input 3 numbers with comma: ");
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
{t=a;a=b;b=t;}
if (a>c)
{t=a;a=c;c=t;}
if (b>c)
{t=b;b=c;c=t;}
printf("\n The result of sort is as following: ");
printf(" %d %d %d \n", a,b,c);
}
c++经典编程题_工学_高等教育_教育专区。编程题C++经典编程题 经典编程题 1. 给定等式 A B C D E 其中每个字母代表一个数字,且不同数字对应不 其中每个字母...
c++程序设计经典例题1_工学_高等教育_教育专区。C语言编程【程序 1】 题目:有 1、2、3、4 个数字,能组成多少个互不相同 且无重复数字的三位数?都是多少? 1...
C++经典编程题 1. 给定等式 A B C D E 其中每个字母代表一个数字,且不同数字对应不 D F G 同字母。编程求出这些数字并且打出这个数字的 + D F G 算术...
c++经典编程题目_其它语言学习_外语学习_教育专区。考试神器本题序号:89 能被 ...其中,y 的值由键盘 输入,变量 c 存贮个数, 变量 m 存放下标。例如, 在 a...
相应的 C 语言 代码引用 K&R C 程序设计一书中给出的代码 void shellsort(int v[], int n) { int gap, i, j, temp; for(gap=n/2;gap>0;gap/=...
C++经典编程题C++经典编程题隐藏>> C++经典编程题 经典编程题 1. 给定等式 A B C D E 其中每个字母代表一个数字,且不同数字对应不 其中每个字母代表一个数...
//数学排列问题解法 #include<iostream.h> void main() { int a,b,c; /...C++经典编程例题(1) printf(" "); for(j=1;j<i+2;j++) printf("%4d...
C++经典入门例题 C++经典入门例题 1.计算机完成一项复杂的数学计算需要 40 000s,编写程序,将其转换成几小时几分几秒的 表示形式。 #include <iostream> using ...
C++经典编程题 中南大学_工学_高等教育_教育专区。这是中南大学最全的C++题目 ...#include <stdio.h> #include <math.h> void main() { float a,b,c,t...
C++ 编程题库_IT/计算机_专业资料。关于C++的很多编程题目。很经典31...{ Complex Complex Complex c3 = s1 s1(3, 4); s2(5, -10); c3;...
热门文档