Interact


私信TA

用户名:Interact

访问量:22009

签 名:

等  级
排  名 654
经  验 3891
参赛次数 0
文章发表 31
年  龄 0
在职情况 学生
学  校 哈尔滨理工大学
专  业

  自我简介:

组 合 数 学 靠 运 气 计 算 几 何 瞎 暴 力 图 论 一 顿 套 模 板 模 拟 只 会 猜 题 意 贪 心 只 能 过 样 例

TA的其他文章

解题思路:

还是for循环和标志变量的使用



注意事项:





参考代码:


要善于调适

#include<stdio.h>

#include<stdlib.h>

int main()

{

int a,b,c,d;

int sum;

int n;

int arr[100];

int temp;

int temp1,temp2,temp3;

int i;

while(~scanf("%d %d",&a,&b))

{

//下

sum=0;

n=1;

temp=1;

while(a!=0)

{

if(a>=b)

{

temp2=b;

while(temp2!=0)

{

sum=sum+2+(n-1)*2;

temp2--;

n++;

}

arr[temp]=sum/b;

temp++;

sum=0;

a=a-b;

}

else

{

temp1=a%b;

temp3=temp1;

// printf("!!!!!!!!!!!!!!!!!!!!!!!!!\n");

while(0!=temp1)

{

sum=sum+2+(n-1)*2;

temp1--;

n++;

}

arr[temp]=sum/temp3;

temp++;

sum=0;

a=0;

}

// printf("!!!!!!!!!!!!!!!!!!!!!!!!!\n");

for( i=1;i<temp;i++)

{

if(i==temp-1)

{

printf("%d\n",arr[i]);

}

else {

printf("%d ",arr[i]);

}

}

}

return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区