Java翻译成C, 请高手帮忙~~~感激不尽

来源:百度知道 编辑:UC知道 时间:2024/06/01 07:42:50
拜托了, 大家~~~哪位高人帮助我一下吧
public class math
{

public static void main(String[] args)
{int a[]=new int[30];
a[0]=1;
a[1]=2;
a[2]=3;
for(int i=3;i<30;i++)
{
a[i]=a[i-1]+a[i-2]+a[i-3];
}
// we make a array to put right answer in;

int b[]=new int [30];

for(int i=0;i<30;i++)
{int ii=i+1;
System.out.println("please input your"+ii+" number");
int temp=StdIn.readInt();
while(check(temp,b,i)==false)
{temp=StdIn.readInt();
};
b[i]=temp;

if(b[i]==0)
{i=30;
}
}

//get your matrix
int tot=0;
for(int i=0;i<30;i++)
{
if(b[i]==-1)
{
b[i]=a[i];
System.out.println("The missing number is: "+b[i]);

}
if(b[i]==0)
{tot=i;
i=30;
}

}
//check which is your missing number<

你给的就是错的
说说这个是干吗的?

照着改了下,不知道你想干什么的 所以。。。

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

int main(void) {
int a[30];
int b[30];
int i;
int tot = 0;

a[0] = 1;
a[1] = 2;
a[2] = 3;

for(i=3; i<30; i++) {
a[i] = a[i-1] + a[i-2] + a[i-3];
}

for (i=0; i<30; i++) {
int temp;

printf("please input your %d number\n",i+1);
scanf("%d",&temp);
while (!check(temp, b, i)) {
scanf("%d",&temp);
}
b[i] = temp;

if (b[i] == 0) {
i = 30;
}
}

for (i = 0; i < 30; i++) {

if (b[i] == -1) {
b[i] = a[i];
printf("The missing number is: %d\n",b[i]);

}

if (b[i] == 0) {
tot = i;
i = 30;
}