① 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;