編程求11213
Ⅰ c++編程 求1+2+3+。。。+n的和 要求不能使用乘除法、for、while、if、else、switch、case等關鍵字以及條件
#include<stdio.h>
int sum;
int stopper = 100;
void yessum(int i);
void nosum(int i);
typedef void(*fnPtr)(int);
fnPtr dispatch[] = { yessum, nosum };
void yessum(int i)
{
sum += i;
dispatch[i / stopper](i + 1);
}
void nosum(int i)
{
/* do nothing. */
}
int main()
{
yessum(1);
printf("%d",sum);
return 0;
}
改好了
Ⅱ 一個php編程問題:假設abcdefghij十個字母分別代表0123456789十個數字......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>NDSBBS 掌機天堂 社區提示信息 - Powered by PHPWind</title>
<meta name="generator" content="PHPWind 7.5 SP3" />
<meta name="description" content="NDSBBS,掌機天堂,社區" />
<meta name="keywords" content="NDSBBS,掌機天堂,社區" />
<base id="headbase" href="http://www.ndsbbs.com/" />
<link rel="stylesheet" type="text/css" href="images/wind-reset.css" />
<style type="text/css">
body{ font-size:12px;background:#fcfcf3;}
a{ text-decoration:none;color:#3366cc;}
a:hover{ text-decoration:underline;}
ol{list-style-type:decimal;margin-left:24px;color:#888;}
.mt10{margin-top:10px;}
.lh2{line-height:2;}
.tip-page{width:600px;margin:100px auto 30px;}
.tip-table{margin:0 1px;background:#ffffff;width:598px;}
.tip-top{background:url(images/tip-top.png) center no-repeat;height:50px;}
.tip-bgA,.tip-bgB,.tip-bgC,.tip-bgC {background:#3366cc;}
.tip-bgA,.tip-bgB{height:1px;overflow:hidden;}
.tip-bgA{margin:0 2px;}
.tip-bgB{margin:0 1px;}
.tip-bgC{padding-top:1px;}
.tip-content{padding:0 0 0 67px;}
.tip-content tr td{padding:5px 10px 5px 0;line-height:25px;}
.show-back{ text-decoration:underline;display:block;padding-right:25px;line-height:22px;overflow:hidden;background:url(images/tips-back.gif) right 0 no-repeat;height:20px;}
.show-back:hover{ background-position:right -20px;}
.btn{border-color:#3366cc;margin-right:1em;color:#fff;background:#3366cc;}
.btn,.bt{border-width:1px;cursor:pointer;padding:.1em 1em;*padding:0 1em;font-size:9pt; line-height:130%; overflow:visible;}
.bt{cursor:pointer;background:#f7f7f7 url(images/wind/btn.png) 0 -52px repeat-x;vertical-align:middle;border-color: #e4e4e4 #cccccc #cccccc #e4e4e4;}
/*form*/
input{font:12px Arial;padding:1px 3px 0 3px;vertical-align:middle;margin-bottom:1px;}
.input{border: 1px solid; border-color: #c0c0c0 #ededed #ededed #c0c0c0;padding:2px 0px 2px 1px;font-size:1.0em;vertical-align:middle;color:#000;}
</style>
<SCRIPT type="text/javascript" language="JavaScript" src="js/core/core.js"></SCRIPT>
<script language="JavaScript">
function showcustomquest(qid){
getObj("customquest").style.display = qid==-1 ? '' : 'none';
}
function opencode() {
getObj('ckcode').src = 'ck.php?nowtime=' + new Date().getTime();
}
</script>
</head>
<body>
<div class="tip-page">
<div class="tip-bgA"></div>
<div class="tip-bgB"></div>
<div class="tip-bgC">
<div class="tip-top"></div>
<table cellpadding="0" cellspacing="0" class="tip-table">
<tr><td height="170">
<div class="tip-content">
<div>您沒有登錄或者您沒有許可權訪問此頁面,可能有如下幾個原因:</div>
<div class="mt10">
<ol><li>用戶組許可權:你所屬的用戶組沒有下載附件的許可權</li>
<li>您還不是站點會員,請先登錄站點<br></li></ol></div>
<form action="login.php?" method="post" name="login">
<table width="100%" style="margin:20px 0 0px 0;">
<tr class="vt"><td width="60" onclick="document.login.pwuser.focus();">
<input type="hidden" name="lgt" value="0"/>用戶名
</td>
<td><input class="input" type="text" tabindex="11" name="pwuser" alt="請輸入賬戶" /></td></tr>
<tr class="vt"><td>密 碼:</td>
<td><input class="input" type="password" tabindex="12" name="pwpwd" alt="請輸入密碼" /></td>
</tr>
<tr class="vt"><td>認證碼:</td>
<td>
<input class="input" type="text" name="gdcode" size="6" tabindex="17" alt="請輸入驗證碼" />
<span style="cursor:pointer; margin-left:3px" onclick="try{opencode()}catch(e){}" >點此顯示驗證碼</span>
<div><img src="images/loading.gif" align="absmiddle" style="cursor:pointer;" id="ckcode" alt="看不清楚,換一張" onclick="try{opencode()}catch(e){}"/></div>
<script language="JavaScript">
opencode();
</script>
</td></tr>
<tr class="vt"><td>隱身登錄:</td>
<td><input name="hideid" type="radio" value="1" /> 是
<input name="hideid" type="radio" value="0" checked tabindex="18" /> 否
</td>
</tr>
<tr class="vt"><td></td>
<td><input class="btn" type="submit" value="登錄" tabindex="19" alt="確定登錄"/>
<a href="sendpwd.php" target="_blank" alt="找回密碼">找回密碼</a>
<a href="register.php" target="_blank" alt="馬上注冊">馬上注冊</a>
<input type="hidden" name="forward" value="" />
<input type="hidden" name="jumpurl" value="http://www.ndsbbs.com/job.php?action=download&aid=17197" />
<input type="hidden" name="m" value="" />
<input type="hidden" name="step" value="2" />
<input type="hidden" name="cktime" value="31536000" />
</td>
</tr>
</table>
</form>
<script language="JavaScript">
document.login.pwuser.focus();
</script>
<div class="tar cc" style="padding:0 20px 20px;">
<a href="http://www.ndsbbs.com" tabindex="20" id="showindex" class="fr">返回首頁</a><span class="fr"></span><a href="javascript:;" onclick="javascript:history.go(-1);return false;" class="fr" tabindex="20">返回繼續操作</a>
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="tip-bgB"></div>
</div>
</body>
</html>
Ⅲ 用C語言編程, 求1+2+3+.....+100的和 跪求啊 ,考試用。
#include<stdio.h>
intmain()
{
intsum=0;
for(inti=1;i<=100;i++)
{
sum+=i;
}
printf("%d ",sum);
return0;
}
Ⅳ 編程求表達式1+2+3+…+n的值,具體要求如下:
#include<stdio.h>
int sumofn(int x)
{
if(x==1) return 1;
return x+sumofn(x-1);
}
int main()
{int n;
scanf ("%d",&n);
int a;
a = sumofn(n);
printf("the sum is :%d",a);
}
樓上的只是沒寫主函數
Ⅳ c#程序編程數字金字塔1 121 12321 1234321 123454321.。。。。。。。。
雙重for循環,自己真的挺慚愧,演算法都知道,我的C++,C#,java簡單語法混淆了。。
int i, j;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= 2 * i - 1; j++)
{
if (j <= i)
{
Console.Write(j); //c++輸出語句 cout<<j;混淆了好久。。
}
else
{
Console.Write(2 * i - j);
}
}
Console.WriteLine("\r");
}
Ⅵ C語言編程求s=1+12+123+12345+123456+1234567+12345678的值
你的題目應該還要加1234吧
# include<stdio.h>
void main()
{
int i,s=1,t=1;
for(i=2;i<=8;i++)
{
t = t*10 +i; //t是這是增量
s += t; //s放和
}
printf("s=%d\n",s);
}
Ⅶ C語言編程計算:s=1 12 123 1234 12345 123456(必須用循環控制語句實現)
這個就是用for實現的
#include<stdio.h>
intmain()
{
intnum=0;
for(inti=1;i<=6;++i)
{
num=num*10+i;
printf("%d",num);
}
printf(" ");
}
運行結果如下:
Ⅷ 編程求1+2+3+……+1000的和,該題設計最合適使用的控制結構為 ( )
選c循環結構
望採納,謝謝!
Ⅸ 1、編程:求1+2+3+4+...+100= p60 (用for循環,while循環,do...while循環)求1*2*3*…*10=
int
sum=0;
for(int
i=1;i<=100;i++)
{
sum+=i;
}
System.out.println(sum);
int
i=1;
sum=0;
while(i<=100)
{
sum+=i;
i++;
}
System.out.println(sum);
sum=0;
i=1;
do
{
sum+=i;
i++;
}
while(i<=100);
System.out.println(sum);這是相加,求相乘只要把sum+=i換成sum*=i就可以了不過貌似相乘結果會超出范圍
呵呵