用c语言求解三道题?

2024-12-02 04:15:25
推荐回答(1个)
回答1:

1:

#include

int main()

{

int n = 1, m;

while (n++)

{

m = n;

for (int i = 1; i <= 9; i++)

{

m = m / 2 - 1;

}

if (m == 1)

{

printf("%d\n", n);

break;

}

}

return 0;

}



2:

#include

int main()

{


int n = 1;

while (n++)

{

if (n % 3 == 2 && n % 4 == 3 && n % 5 == 4 && n % 6 == 5 && n % 7 == 0)

{

printf("%d\n", n);

break;

}

}

return 0;

}




3:

#include

int main()

{


int y, m, d, md[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

int t, s;


scanf("%d %d %d", &y, &m, &d);


for (s = 0, t = 2010; t < y; t++)

{

s += (t % 4 == 0 && t % 100 || t % 400 == 0) + 365;

}


for (s += d, t = m - 2; t >= 0; s += md[t--]);

printf((t = s % 5) == 0 || t == 4 ? "晒网\n" : "打鱼\n");

return 0;

}