C语言难题

[复制链接]
查看11 | 回复4 | 2011-5-14 00:53:36 | 显示全部楼层 |阅读模式
输入一个整数n, 从三的零次方开始到三的二十次方中选择几个数 通过加减算数使得其值等于n . 三的每个次方只能用一次.

回复

使用道具 举报

千问 | 2011-5-14 00:53:36 | 显示全部楼层
不懂请追问#include #include int main(){__int64 n,m;int c,jin,bg,i;int num[21];while(scanf("%lld",&n)==1){m = n;memset(num,0,sizeof(num));c = 0;while(n>0&&c<21){switch(n%3){case 0:n/=3;break;case 1:num[c] = 1;n/=3;break;case 2:n
回复

使用道具 举报

千问 | 2011-5-14 00:53:36 | 显示全部楼层
运行结果是x=4,若你想屏幕上看到这结果,那就在这些语句后面加上这一句:printf("x=%d",x);你好象不知道if语句的用法,介绍如下:if(表达式) 语句1 else 语句2;
if语句执行过程:先计算表达式的值,若表达式的值为“真”(何为真?就是if后面括号里的值只要不是0,就是“真”),若为
回复

使用道具 举报

千问 | 2011-5-14 00:53:36 | 显示全部楼层
#includeusing namespace std;const int max1=8;int num;int store[21];string mark;int a[21];bool ifUsed[21];void putNumbers(void){int k=1;for(int i=0;i<20;++i)
回复

使用道具 举报

千问 | 2011-5-14 00:53:36 | 显示全部楼层
#includeusing namespace std;const int max1=8;int num;int store[21];string mark;int a[21];bool ifUsed[21];void putNumbers(void){int k=1;for(int i=0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行