矩形阵
#include <iostream>
using namespace std;
int main()
{
double a[3][3];
int i,j;
double sum=0;
cout<<"input 3x3 matrix:";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
for(i=0;i<3;i++)
sum+=a[i][i];
cout<<"sum="<<sum<<endl;
}
字符串
#include<iostream>
#include <string>
using namespace std;
int main()
{
string a;
string b;
cout<<"请输入字符串a:";
cin>>a;
cout<<"请输入字符串b:";
cin>>b;
cout<<endl;
if(a==b)
cout<<"两个字符串相等"<<endl;
else
cout<<"两个字符串不相等"<<endl;
cout<<a+b<<endl;
}