Ⅰ c語言題 在控制台輸入一句話,利用while循環輸出這句話10遍。求代碼!!!
#include<stdio.h>
int main()
{
int i = 0;
char a[128] = {0};
scanf("%s", a);
while(i++ < 10)
printf("%s",a);
return 0;
}
Ⅱ 新手提問:C語言如何輸出一句話啊,具體怎麼做
我把完整的代碼給你吧!
#include 「stdio.h」//這個是頭文件
void main()//這個是主函數
{
printf("hello word\n");
}
你直接把這段代碼拷貝過去就可以實現你要的功能了。
覺得有幫助的話,請採納,謝謝!
Ⅲ C語言,怎調用函數輸出一句話
這樣就可以了:
#include<stdio.h>
intmain()
{
voidcu();
cu();
return0;
}
voidcu()
{
printf("中國");
}
Ⅳ C語言程序中明明只要求列印一句話,結果運行時她一句話列印了兩遍
改為花括弧:
{ for (...); // 加分號
printf("。。導入完畢");
}
Ⅳ C語言怎樣輸入一個名字後輸出一個特定句子
源代碼如下:
#include<stdio.h>
#include<string.h>
voidmain()
{
charstr[100];
printf("請輸入張三:");
scanf("%s",str);
if(strcmp(str,"張三")==0)//兩個字元串相等時,strcmp返回0
{
printf("我傻瓜 ");
}
else
{
printf("你輸入的是:%s ",str);
}
(5)c語言輸入一句話列印一句話擴展閱讀
源代碼編輯的注意事項
1、定義一個變數存放輸入的數字,寫一個for循環,循環次數就是輸入的這個數字,循環體裡面就是循環拼接輸出的特定的字元,最後輸出就可以。
2、利用for循環控制輸出的字元,意思是當i<=n時,則執行循環內的語句,然後加1再進行判斷;當條件不符時,跳出這個循環。
Ⅵ C語言函數調用怎麼輸入一句話輸出另一句
這個還真就不知道
Ⅶ c語言如何實現逐個輸出一段話
1、使用sleep函數暫停,用pirntf %c參數一個個輸出即可。
2、常式:
#include<stdio.h>
#include<windows.h>
#include<string.h>
intmain()
{
charc[]={"你好,中國!"};
inti;
for(i=0;i<strlen(c);i++)
{
printf("%c",c[i]);
Sleep(100);//休眠100毫秒
}
printf(" ");
return0;
}
Ⅷ 在C語言中如何實現「讓一句話在屏幕上重復不斷的列印出來直至我設置的那個時間點結束」
// 參數:年、月、日、時、分、秒和你要顯示的那句話
void MyPrint(int year, int month, int day, int hour, int minute, int second, char *text)
{
while (text != NULL)
{
time_t t = time(NULL);
struct tm *now = localtime(&t);
if (year - 1900 == now->tm_year && month - 1 == now->tm_mon && day == now->tm_mday
&& hour == now->tm_hour && minute == now->tm_min && second == now->tm_sec)
{
break;
}
else
{
printf("%s\n", text);
}
}
}
// 使用
int main()
{
// 在2012年5月18日12點以前,一直列印"Hello World"這句話
MyPrint(2012, 5, 18, 12, 0, 0, "Hello World");
return(0);
}
Ⅸ 輸入一個數然後輸出一句話的程序用C語言怎麼編寫
用if或switch語句如`:
switch((int)x)
{
case 9:printf("你好\n");break;
case 8:printf("您好\n");break;
case 7:printf("我愛你\n");break;
case 6:printf("......\n");break;
default:printf("重慶\n");
}
你輸入6,7,8,9,分別輸出相應的話 這只是部分 你還要在前面加上預處理和主函數
Ⅹ c語言中,使用scanf輸入一句話,中間有空格,怎樣用printf將這句話列印出來
#include<stdio.h>
int main()
{
char a[50];
int i=0;
scanf("%c",&a[i]);
while(a[i] != '\n')
{
i++;
scanf("%c",&a[i]);
}
for( int j=0;j<i;j++)
printf("%c",a[j]);
return 0;
}
直接scanf("%s",a);
scanf會遇到空格就結束輸入了 所以用在用字元串時gets好些