C语言题目 请达人帮我解答一下吧 越快越好 3Q

来源:百度知道 编辑:UC知道 时间:2024/09/28 11:13:50
1。编一个程序,先随机产生100个两位正整数并输出,再找出其中最小的和次最小的正整数(可能相等)?要求不对这100个正整数进行排序。
2。编一个程序,求满足下面条件的100以内的所有自然数对:两个自然数的和与差都是完全平方数。如:17和8 (17 + 8 = 25, 17 – 8 = 9)。

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>

void randomNumbers();
void squares();

void main()
{
randomNumbers();
squares();
}
void randomNumbers()
{
int arrInts[100];
int startMax=10;
int startMin=99;
srand(time(0));
for (int i=0; i<100; i++)
{
arrInts[i]=rand()%90+10;
if (arrInts[i]>startMax) startMax=arrInts[i];
if (arrInts[i]<stratMin) startMin=arrInts[i];
}
printf("max:%d, min:%d", startMax, startMin);
}

void squares()
{
int temp1, temp2;
for (int i=0; i<100; i++)
{
for(int j=0; j<100; j++)
{
temp1 = i-j;
temp2 = i+j;

if ((double)temp1 = sqrt(temp1)*sqrt(temp1) && (double)temp2 = sqrt(temp2)*sqrt(temp2) )
printf("(%d,%d)&#