C++ 编程 while 循环Create a while loop. Before the loop, ask the

ningmengdelei2022-10-04 11:39:541条回答

C++ 编程 while 循环
Create a while loop. Before the loop, ask the user to enter an integer. Go through the loop as many times as the number entered. Keep count of the number of times you’ve gone through the loop and print this number in the loop.

已提交,审核后显示!提交回复

共1条回复
hufangqiao 共回答了15个问题 | 采纳率86.7%
int num;
printf("Please enter a int : ");
scanf("%d",&num);
while(num>0)
{
printf("%dn",num);
num--;
}
1年前

相关推荐

c语言翁凯期末考试字数统计编程答案
c语言翁凯期末考试字数统计编程答案
题目内容:
你的程序要读入一篇英文文章,然后统计其中的单词数来输出。需要统计的数据为:
1. 总的单词数量;
2. 含有1个字母到10个字母的单词的数量。
单词和单词的间隔是由以下标点符号形成的:空格、tab、回车换行、逗号、句号、问号、括号、双引号和冒号。这些符号不能被计入单词的长度中。
因此,对于下面的句子:
"what you see is a very hefty response," said cnn aviation correspondent rene marsh.
其中的单词为:
what you see is a very hefty response said cnn aviation correspondent rene marsh
共14个。注意虽然这里的response,"后面跟了空格,我们并不能保证所有的输入中都会有这样规矩的空格。
单引号(表示缩写的')和连字号(-)视做单词的一部分,所以“he's”是一个单词,长度为4;而“f-16 fighter jets”是三个单词。为了你的程序的方便,输入数据中不会出现两个连续的连字号。
输入格式:
一篇英文文章。
如何知道输入结束了?
* 如果使用scanf,它会返回这次读到了几个变量的值,当这个值小于你要求读的变量的数量时,表示输入结束了;
* 如果使用getchar,它在输入结束时返回eof。
输出格式:
十一个数字,依次是单词数量和含有1到10个字母的单词的数量,以空格分隔,最后不含空格。
输入样例:
f-16 fighter jets escorted two passenger planes into atlanta's hartsfield-jackson international airport on saturday after a bomb threat made on *** was deemed credible, according to military officials.
southwest airlines flight 2492 and delta flight 1156 landed safely at the airport and were searched by bomb disposal units, according to airline officials. nothing out of the ordinary was found, officials said.
delta spokesman morgan durant said, "it was a portland, oregon, to atlanta, georgia, flight. delta is supporting the sweeping process carried out by authorities."
输出样例:
85 2 11 11 11 6 11 10 10 9 1
Hikkis1年前1
renyanyi 共回答了12个问题 | 采纳率100%
#include#includeint main(){ /* FILE *fp; fp=fopen("C:\1.txt","r"); */ char ch; int wordnum[10]={0}; int i,isword=0,isbegin=0,wordsize=0; int wordcount=0; //ch=fgetc(fp); ch=getchar(); while(1){ //printf("%c",ch); if(ch==' '||ch=='t'||ch=='n'||ch==','||ch=='.'||ch=='?'||ch=='('||ch==')'||ch=='"'||ch==':'||ch==EOF){ if(isword==1){ if(wordsize
android 编程新手求救[2011-05-02 14:24:10 - SAXParseXml] Installati
android 编程新手求救
[2011-05-02 14:24:10 - SAXParseXml] Installation failed due to invalid APK file!
[2011-05-02 14:24:10 - SAXParseXml] Please check logcat output for more details.
[2011-05-02 14:24:10 - SAXParseXml] Launch canceled!
05-04 17:35:31.094: WARN/PackageParser(261): Unable to read AndroidManifest.xml of /data/local/tmp/xml4.apk
05-04 17:35:31.094: WARN/PackageParser(261): java.io.FileNotFoundException: AndroidManifest.xml
05-04 17:35:31.094: WARN/PackageParser(261): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
05-04 17:35:31.094: WARN/PackageParser(261): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:486)
这个项目就是sax解析xml,一单元测试和运行就报这个错,运行不起来.我测试其他的项目 没有问题!我测试了一个下午了,貌似就是解析xml文档就出错,求解,谢谢~~~
顺带发现android好不稳定,经常代码改过了,运行还是以前的结果 ,怎么办?一并求解~~~~~~~~~
但是我的文件肯定在啊,也不可能有错啊,就是报这种莫名其妙的错误.
愿意帮我远程解决问题的加Q:763585627 晚上10点以后绝对在.其余时间可能在.
webson1年前1
到处走走瞧瞧 共回答了16个问题 | 采纳率87.5%
他的问题已经解决 ,写点让后人参考吧,他的项目是解析xml文件.
他把person.xml放在了src文件夹下,就会报上述错误.去掉放入手机sdcard中就ok了
lingo编程错误model:sets:C1/1..3/:; C2/1..8/:; C3/1..7/:; S1/1..1
lingo编程错误
model:
sets:
C1/1..3/:;
C2/1..8/:;
C3/1..7/:;
S1/1..17/:;
S2/1..16/:GH,GQ;
L1(S1,S1):d;
L2(C1,C2,S1):F;
endsets
data:
d=
0 38 30 42 42 51 63 81 61 69 22
38 0 39 36 36 45 57 75 55 63 16
30 39 0 15 40 49 58 63 43 42 24
42 36 15 0 25 34 43 48 28 27 20
42 36 40 25 0 9 21 39 19 32 20
51 45 49 34 9 0 19 39 27 40 29
63 57 58 43 21 19 0 20 22 35 41
81 75 63 48 39 39 20 0 20 33 59
61 55 43 28 19 27 22 20 0 13 39
69 63 42 27 32 40 35 33 13 0 47
22 16 24 20 20 29 41 59 39 47 0
;
GH=10,15,6,9,13,6,11,4,13,17,11,2,11,21,13,14;
GQ=9,14,5,10,9,10,13,9,15,9,6,7,13,15,10,16;
enddata
min=2/65*@sum(C1(i):@sum(C3(p):
@sum(L1(k,q)|k#ne#q:d(k,q)*F(i,p,k)*F(i,p+1,q))*
(65-
@sum(C2(j):@sum(S2(k):F(i,j,k)*GH(k)))
-@sum(C2(j)|j#le#p:@sum(S2(k):F(i,j,k)*(GQ(k)-GH(k))))
)
38 ));
总工作时间;
@for(C1(i):
5/60*@sum(C2(j):@sum(S2(k):F(i,j,k)))+
1/30*@sum(C3(j):@sum(L1(k,q)|k#ne#q:F(i,j,k)*F(i,j+1,q)*d(k,q)))
mengqd51861年前1
AlexDelPiero 共回答了22个问题 | 采纳率77.3%
你定义d的时候是17×16的矩阵,而给数据的时候却只给出11×11个数据.不吻合.
看看数据是不是拷错了
Lingo部分编程问题SETS:BUILDING/B1..B87/:DEMAND;POINT/P1..P100/:MAX
Lingo部分编程问题
SETS:
BUILDING/B1..B87/:DEMAND;
POINT/P1..P100/:MAXCAPACITY;
LINKS(BUILDING,POINT):DISTANCE,CAPACITY;
此处补充两条语句
语句一:目标函数为CAPACITY之和最小
语句二:CAPACITY与对应的DISTANCE相乘的积累加为0
@FOR(POINT(J):
@SUM(BUILDING(I):CAPACITY(I,J))=DEMAND(I));
DATA部分我自己补充
biaoge2061年前1
风行天下119 共回答了23个问题 | 采纳率91.3%
相加为0的条件很奇怪SETS:BUILDING/B1..B87/:DEMAND;POINT/P1..P100/:MAXCAPACITY;LINKS(BUILDING,POINT):DISTANCE,CAPACITY;ENDSETSMIN=@SUM(LINKS:CAPACITY);@SUM(LINKS:DISTANCE*CAPACITY)=0;@FOR(POINT(J):@SUM(...
加工中心编程实例,使用旋转坐标G68,
glliangailin1年前1
ee老东吴 共回答了10个问题 | 采纳率90%
G68x0y0r15
x0y0为旋转圆心,R15为旋转角度
G69取消
lingo编程错误1017,modelsets:ycd/yc1..yc5/;wlyq/wl1..wl4/:z,e,f,c
lingo编程错误1017,
model
sets:
ycd/yc1..yc5/;
wlyq/wl1..wl4/:z,e,f,c;!z、e都是0-1函数,0表示不存在,1表示存在;
nmsc/nm1..nm30/:m;
link1(ycd,wlyq):q,d,x;!q,d已知x为未知数;
link2(wlyq,nmsc):r,l,y;!r,l已知y为未知数;
a;!a表示一个极小数;
endsets
data
a=0.000001;
q=5.6;
d=11.9 19.7 10.8 39.3
17.5 35.5 25.2 13.2
25.1 15.3 21.0 20.2
18.1 20.4 16.9 15.5;
r=4.9;
l=3.6 4.2 1.9 5.9 8.7 11.5 4.3 5.7 15.9 24.1 16.5 5.2 8.9 11.3 6.7 21.0 13.5 14.9 16.2 10.6 9.8 3.2 5.9 12.8 20.7 9.6 4.9 12.5 18.9 6.8
8.5 20.1 19.5 21.3 10.2 8.9 4.3 16.5 17.9 13.2 9.5 12.9 14.9 27.5 13.2 5.9 19.2 25.8 13.4 9.5 12.9 5.6 8.7 4.3 15.8 19.6 12.3 2.8 14.9 15.9
8.9 24.6 21.9 9.4 2.3 4.9 10.9 7.9 16.3 19.4 9.8 4.6 24.9 21.9 5.9 8.1 23.6 4.6 8.9 12.8 4.9 7.2 5.4 12.9 25.0 16.4 15.9 13.8 7.9 9.4 ;
m=120 430 340 210 190 100 370 220 350 290 220 210 110 270 440 410 460 220 370 450 380 270 290 110 230 100 390 180 440 330;
c=(2.3 4.6 1.3 4.0);
enddata
min=@sum(link1:q*d*x)+@sum(link2:r*l*y)+z*e*f*c;
@bin z(@sumlink1(i.j)-a>0);
@bin e(@sum(link1(i,j))-@sum(link2(i,j))-a>0);
@for(f=@sum(link1(i,j))-@sum(link2(i,j)));
@for(wlyq(J):
@sum(wlyq(J):nmsc(J,K)>m));
end
evercancer1年前1
yeloshen 共回答了16个问题 | 采纳率100%
很多问题哦
model:后有冒号
a是一个数,不要再sets中定义
确认d,l中的个数是否与sets中定义的一致