修改下为C语言 谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/21 12:13:51
#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 61;
bool s[MAXN];
int main(){
int n, d, r = 0;
while (scanf("%d%d", &n, &d) != EOF && !(n == 0 && d ==0)){
memset(s, 0, sizeof(s)); r = 0;
while (!s[n]){
s[n] = true; n = (n + n * d) % 60; ++r;
if (n == 0) break;
}
if (n != 0) printf("Impossible\n"); else printf("%d\n", r);
}
return 0;
}
最好直白点 旁边在加上注释最好
#include<stdio.h>
void main()
^^^^^^^^^^^
^^^然后接下去

//不要名字空间,头文件包含方法如下
#include <stdio.h> //c标准输入出
#include <memory.h>

#define MAXN 61//c里面常量的定义,不是const
bool s[MAXN];

int main()
{
int n, d, r = 0;
while (scanf("%d%d", &n, &d) != EOF && !(n == 0 && d ==0))
{
memset(s, 0, sizeof(s));
r = 0;
while (!s[n])
{
s[n] = true;
n = (n + n * d) % 60;
++r;
if (n == 0)
break;
}
if (n != 0)
printf("Impossible\n");
else printf("%d\n", r);
}
return 0;
}

修改完成,VC 6.0通过编译。

自己动手吧…………

你想干么?

#include <iostream.h>
#include <stdio.h>
#include <string.h>
#define MAXN 61
enum booll {right=1,wrong=0}s[MAXN];

int main(){
int n, d, r = 0;
while (scanf("%d%d", &n, &d) != EOF && !(n == 0 && d ==0)){
memset(s, 0, sizeof