我写的程序哪里有错误了呢

 

这是你图片中矩阵水平翻转的代码,请采纳

# include<iostream>
using namespace std;
#define N 4
int main()
{
	cout<<"请输入"<<N*N<<"个整数:";
	int a[N][N];
	int i,j;
	for(i=0;i<N;i++)
		for(j=0;j<N;j++)
			cin>>a[i][j];
	cout<<endl;

	for(i=0;i<N;i++)
	{
		for(j=0;j<N/2;j++)
		{
			int t = a[i][j];
			a[i][j] = a[i][N-j-1];
			a[i][N-j-1] = t;
		}
	}

	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
			cout<<a[i][j]<<"\t";
		cout<<endl;
	}

	return 0;
}

 

最好吧报错结果和代码发出来

中文应该注释掉,中间的空格输出可以删除,斜杠写反了,\t改为双引号,再试试

 

 

 

代码如下,如有帮助,请采纳一下,谢谢。

#include <iostream>
using namespace std;
#define n 4
int main()
{
	float a[n][n];
	int i ,j;
	float tmp;
	for (i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
			cin >> a[i][j];
	}

	for (i = 0; i < n; i++)
	{
		for(j = 0; j < n/2; j++)
		{
			tmp = a[i][j];
			a[i][j] = a[i][n-j-1];
			a[i][n-j -1] = tmp;
		}
	}

	for (i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
		{
			cout << a[i][j] << '\t';
		}
		cout << endl;
	}
	//system("pause");
	return 0;
}

您的问题已经有小伙伴解答了,请点击【采纳】按钮,采纳帮您提供解决思路的答案,给回答的人一些鼓励哦~~

ps:开通问答VIP,享受5次/月 有问必答服务,了解详情↓↓↓

【电脑端】戳>>>  https://vip.csdn.net/askvip?utm_source=1146287632
【APP 】  戳>>>  https://mall.csdn.net/item/52471?utm_source=1146287632