工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1401|回复: 14

贴贴今天六道题的源码

[复制链接]
发表于 2005-7-21 22:23 | 显示全部楼层 |阅读模式
1414
#include<stdio.h>
int main(int argc, char* argv[])
{
int i,j,k,n;
scanf("%d",&n);
while (n>0){
  n--;
  scanf("%d %d",&i,&j);
  if (i==j){
   if ((i&1)==0) printf("%d\n",i*2);else
      printf("%d\n",i*2-1);
  }else
  if (i==j+2){
     if ((i&1)==0) printf("%d\n",i*2-2);else
      printf("%d\n",i*2-3);
  } else
  printf("No Number\n");
}
getchar();
        return 0;
}
 楼主| 发表于 2005-7-21 22:23 | 显示全部楼层
1494
#include<stdio.h>
int main(int argc, char* argv[])
{
int i,j,k,a,b,c;
scanf(\"%d %d %d\",&a,&b,&c);
while (a>0 && b>0 && c>0){
  c=b-c;
if (a<=b) printf(\"1\\n\");else{
  i=(a-b)/c;
  if (i*c!=a-b) i++;
  printf(\"%d\\n\",i*2+1);
}
scanf(\"%d %d %d\",&a,&b,&c);
}

        return 0;
}
回复

使用道具 举报

 楼主| 发表于 2005-7-21 22:24 | 显示全部楼层
1476
#include<stdio.h>
#include<string.h>
int main()
{
  int i,j,k,n;
  int num[61];
  while(scanf(\"%d %d\",&n,&k),n)
   {
           for (i=0;i<61;i++) num=0;
           num[n]=1;
           j=0;
           while(!num[0])
           {
                   n=(n+n*k)%60;
                   j++;
                   if(num[n])break;
                   num[n]=1;
           }
           if(n>0 && num[n])
                   printf(\"Impossible\\n\");
           else
           printf(\"%d\\n\",j);

   }
  return 0;
}
回复

使用道具 举报

 楼主| 发表于 2005-7-21 22:26 | 显示全部楼层
1405
#include<stdio.h>
int main(int argc, char* argv[])
{
int i,j,k,a,b,go[27],n;
char c;
scanf(\"%d\",&n);
while (n>0){
  for (i=0;i<27;i++) go=0;
  a=0;b=0; k=0;
  getchar();
  while ( 1){
   scanf(\"%c\",&c);
  if (c==10)
  break;
  i=c-65;
  if (go==0){
   if (a<n){a++;go=1;}else {b++;go=2;}
  }else if (go==1){
   a--;go=0;
  } else if (go==2){
   if (a>=n) {k++;}
   go=0;
  }

  }
  if (k==0) printf(\"All customers tanned successfully.\\n\");else
  printf(\"%d customer(s) walked away.\\n\",k);
  scanf(\"%d\",&n);
}

        return 0;
}
回复

使用道具 举报

 楼主| 发表于 2005-7-21 22:26 | 显示全部楼层
1402
#include<stdio.h>
int main(int argc, char* argv[])
{
int num[31],n,i,j,total;
scanf(\"%d\",&n);
while (n>0){
  total=0;
  for (i=0;i<n;i++) {scanf(\"%d\",&num);total+=num;};
  if ((total&1)==0){
    total=total/2;
    j=0;
    for(i=0;i<n;i++) {
     j+=num;
     if (j>total) {printf(\"No equal partitioning.\\n\");break;}else
      if (j==total){
       printf(\"Sam stops at position %d and Ella stops at position %d.\\n\",i+1,i+2);
       break;
      }
    }
  } else
  {
   printf(\"No equal partitioning.\\n\");
  }
  scanf(\"%d\",&n);
}
        return 0;
}
回复

使用道具 举报

发表于 2005-7-21 22:28 | 显示全部楼层
恩~~很好~~支持~~
回复

使用道具 举报

发表于 2005-7-22 12:20 | 显示全部楼层
俺看不懂。。。佩服考试强人。。。
回复

使用道具 举报

 楼主| 发表于 2005-7-22 21:02 | 显示全部楼层
这和考试差距差大了.
回复

使用道具 举报

 楼主| 发表于 2005-7-22 21:03 | 显示全部楼层
考试都是很死的东西.
这里大部分都是现实生活中各种实际问题的模型.或者一些理论的简化的题目.
很有实际意义,更能帮助提高编程水平.
回复

使用道具 举报

发表于 2005-7-23 13:21 | 显示全部楼层
熟看代码三百题,不会做题也会编!要想编程好,首先要看多点好的代码。小康的代码很乱的,大家不怕看到头晕就看吧。也是煅炼吧
回复

使用道具 举报

发表于 2005-7-23 15:18 | 显示全部楼层
这几个程序内容太累赘了
回复

使用道具 举报

发表于 2005-7-23 15:37 | 显示全部楼层
心情不好,路过


“学号”版主留言:编程版主不在,我会周不时过来看看,不要乱水,人家讨论问题,你也凑热闹,下次一定删帖扣分处理

[ Last edited by 2002070344 on 2005-7-23 at 09:08 ]
回复

使用道具 举报

 楼主| 发表于 2005-7-24 08:07 | 显示全部楼层
\"第11楼  

这几个程序内容太累赘了
\"

\"累赘\" 是什么意思啊?
回复

使用道具 举报

发表于 2005-7-25 10:12 | 显示全部楼层
可以去掉很多代码的
回复

使用道具 举报

发表于 2005-7-25 10:12 | 显示全部楼层
可以去掉很多代码的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-5-14 00:41

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表