① c语言 输入一个正整数repeat(0<repeat<10),做repeat次下列运算: 读入一个正整数n(n<=100),
源代码如下:
#include <stdio.h>void sign(int x)
{
if (x > 0)
{
printf("sign(%d)=1 ", x);
}
else if(x < 0)
{
printf("sign(%d)=-1 ", x);
}
else
{
printf("sign(%d)=0 ", x);
}
void main()
{
int num = 0, x;
int i;
scanf("%d", &num);
for (i = 0; i < num; i++)
{
scanf("%d", &x)
sign(x);
}
(1)c语言repeat用法扩展阅读
1、repeat循环是一种无条件循环,它需要在循环体中设置终止条件,并使用break语句进行退出。
2、repeat结构控制方式比较特别,当进入循环体后,直到until条件为真时才结束,而其它语言的do-while是当条件为假时才结束循环。
② c语言怎么编写一个程序:输入一个正整数repeat(0<repeat<10),做repeat次运算
#include<stdio.h>
#include<ctype.h>
intmain()
{intrepeat,zm,kg,sz,qt,i;
chars[200];
scanf("%d%*c",&repeat);
while(repeat--)
{zm=kg=sz=qt=0;
gets(s);
for(i=0;s[i];i++)
if(isalpha(s[i]))zm++;
elseif(s[i]=='')kg++;
elseif(isdigit(s[i]))sz++;
elseqt++;
printf("letter=%d,blank=%d,digit=%d,other=%d
",zm,kg,sz,qt);
}
return0;
}
③ C语言,输入一个正整数repeat (0<repeat<10),做repeat 次运算 输入正整数n再输入n 个整数,输出最大值。
#include<stdio.h>
intmain(){
inti,max,repeat,n,m;
scanf("%d",&repeat);//数据组数
while(repeat--){
scanf("%d",&n);//每组数据个数
scanf("%d",&max);//先读入一个数做基准
for(i=1;i<n;i++){
scanf("%d",&m);
if(m>max)max=m;
}
printf("%d ",max);
}
return0;
}
④ repeat用法
repeat用法:
一:形容词
回头客的,再次光顾的。
We tender you our best thanks for your kind order, and hope to receive your repeat order.
对于本次订购,我们深表感谢,望再次订购。
二:名词
1、再次发生;重复(的事物)。
There were fears that there might be a repeat of last year's campaign of strikes.
有人担心去年的罢工运动可能再次发生。
2、重播,重演
There's nothing except sport and repeats on TV.
除了体育节目和重播节目外,电视上没什么新鲜内容。
三:动词
1、重复,复制,重复发生;重写;重做
Am I expected to repeat it?
要不要我重复一遍?
2、复述,转述,反复说,背诵
Repeat your lesson.
背诵你的功课。
3、【美】(在选举中违法)重复投票
In order to avoid repeating all voters have to be registered in the district.
为了防止重复投票,所有选民都要在区里进行登记。
(4)c语言repeat用法扩展阅读:
词义辨析
cite, quote, repeat这些动词均含“引用,复述”之意。区别在于:
1、cite指引经据典以示证明或凭据。
2、quote指不加剪裁的直接引用原文或原话。
3、repeat仅强调口头或笔头重复别人的话或字句,并不必指明出处。
⑤ C语言 输入一个正整数repeat(0<repeat<10),做repeat次下列运算: 读入一个正整数n(n<=50),输出n!
先加上输入语句的&
你做p=p*i 结果是p,最后输出了一个n..
printf("p=%d\n",n);→ printf("p=%d\n",p);
⑥ C语言goto语句问题:goto loop与goto repeat有什么区别吗
goto loop;
goto repeat;
loop 和 repeat 都是标号(就像是路牌),goto这个标号,也就是转向去那个目的地。
loop 和 repeat 是不同的路牌,那么 目的地 不同,两者不同。
英文意思:loop -- 循环。repeat -- 重复。
下面两段程序 只是 标号 名不同,做的事一样。
--------------------------
s=0; n=0;
loop:
n=n+1;
s=s+n;
if (n<10) goto loop;
printf("n=%d s=%d\n",n,s);
----------------------------
s=0; n=0;
repeat:
n=n+1;
s=s+n;
if (n<10) goto repeat;
printf("n=%d s=%d\n",n,s);
========================
下面例子两个标号,目的地不同。
x > 0, 计算 y=1/x; x==0 得 y=0;x<0 重新输入:
repeat:
scanf("%d",&x);
if (x > 0) goto loop; else if (x<0) goto repeat;
y = 0; return y;
loop:
y = 1/x;
return y;