本文发布于 1248 天前,最后更新于 1104 天前,其中的信息可能已经有所发展或是发生改变。
#include <bits/stdc++.h>
using namespace std;
int a[120][120];
int temp[1008611];
int maxx[120];
int main()
{
cout << "生成了一个九九乘法表作为数据"<< endl;
for(int y=1; y<=10; y++)
{
for(int x=1; x<=10; x++)
{
a[y][x] = x*y;
if(a[y][x] <10) cout << ' ';
cout << a[y][x] << ' ';
}
cout << endl;
}
for(int y=1; y<=10; y++)
{
for(int x=1; x<=10; x++)
{
maxx[y] +=a[y][x];
}
}
for(int y=1; y<=10; y++)
{
printf("%s%d%s %d\n","a[",y,"][MAX] ",maxx[y]);
}
}
两道水题,就不做解释了
#include <bits/stdc++.h>
using namespace std;
int a[120][120];
int temp[1008611];
int maxx[120];
int ans = 0;
bool judge_prime(int a)
{
for(int i = 2; i * i <=a; i++)
{
if(a%i ==0)
{
return false;
}
}
return true;
}
int main()
{
cout << "生成了一个九九乘法表作为数据"<< endl;
for(int y=1; y<=10; y++)
{
for(int x=1; x<=10; x++)
{
a[y][x] = x*y;
if(a[y][x] <10) cout << ' ';
cout << a[y][x] << ' ';
}
cout << endl;
}
for(int y=1; y<=10; y++)
{
for(int x=1; x<=10; x++)
{
if(judge_prime(a[y][x])) ans++;
}
}
cout << "所以表中素数个数" << ans;
}