C語言打早安
#include<stdio.h>
intmain(void)
{
printf("早安,河北工程 ");
return0;
}
② C語言中怎麼輸入數字和字母
需要准備的材料分別有:電腦、C語言編譯器。
1、首先,打開C語言編譯器,新建一個初始.cpp文件,例如:test.cpp。
③ 如何用C語言寫新年祝福
C語言:
#include <stdio.h>
int main()
{
printf("Happy new year!");
return 0;
C++語言
#include <iostream>
using namespace std;
int main()
{
cout << "Happy new year!";
return 0;
}
(3)C語言打早安擴展閱讀
C語言特點
(1)簡潔的語言
C語言包含的各種控制語句僅有9種,關鍵字也只有32 個,程序的編寫要求不嚴格且以小寫字母為主,對許多不必要的部分進行了精簡。實際上,語句構成與硬體有關聯的較少,且C語言本身不提供與硬體相關的輸入輸出、文件管理等功能,如需此類功能,需要通過配合編譯系統所支持的各類庫進行編程,故c語言擁有非常簡潔的編譯系統。
(2)具有結構化的控制語句
C語言是一種結構化的語言,提供的控制語句具有結構化特徵,如for語句、if⋯else語句和switch語句等。可以用於實現函數的邏輯控制,方便麵向過程的程序設計。
④ 用c語言怎麼打出 * ** *** ****
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
return 0;
}
⑤ 怎麼用C語言編程 用星形(』*』)打出一個春節的春字
需要先把「春」
生成點陣字模(一個二維數組,元素為0或者1),然後根據這個逐個讀取,0輸出空格,1輸出*號
,
漢字點陣字模
生成工具
網上搜一個就可以了
⑥ 求c語言打字游戲程序,要求如下:
//頭文件stdio.h,conio.h,time.h
int
main()
{//首先列印信息
getch();
char
a,b;
int
t,s;
s=time();//獲取系統時間,以秒為單位,存入s中
for(;;)
{t=time();
if(t-s>=60)break;//假設規定時間是60秒
a=(char)rand();//隨機生成數字(返回int型,需要強制轉換)
/*rand每次生成的隨機數相同,
需要用系統時間初始化隨機數生成器,
相關內容可以到網路查*/
for(a<'a'||a>'z')a=(char)rand();//如果不是小寫字母,重新生成
printf("%c",a);
b=getch();
if(a==b);//正確
else
printf("\b_");//\b代表backspace,錯誤時列印_
}
getch();//結束
}
//當然,如有興趣,可以定義兩個int型變數,分別記錄總字數和敲對的字數
⑦ 編程高手請進!(C語言)
1.
#include <stdio.h>
#include<stdlib.h>
#include<ctype.h>
main()
{
int count;/*猜數字的次數*/
int number;/*系統產生的隨機數字*/
int guess;/*程序員輸入數字*/
char yes='Y';
clrscr();
printf("\nNow let us play the game.\n Guess the number:");
while (toupper(yes)=='Y')
{
count=0;
randomize();
number=random(100)+1;
do
{
do
{
printf("\nInput an integer number(1~100):");
scanf("%d",&guess);
}while(!(guess>=1&&guess<=100));/*結束第二層DO~WHILE循環*/
if (guess<number)
printf("\n Your answer is low,try again!");/*如果用戶輸入的數字小於系統隨機數,則輸出數字太小的提示信息*/
if (guess>number)
printf("\n Your answer is high,try again!");/*如果用戶輸入的數字大於系統隨機數,則輸出數字太小的提示信息*/
count++;/*猜測次數加一*/
if (count==15)
{
printf("\n This is the %d times! Think it hard next!",count);
exit(0);/*如猜測15次還沒猜對,則退出遊戲*/
}
}while (!(guess==number));
if (count<=7)/*猜測的次數小於7次*/
{
printf("\n You have got it in %d times.\n",count);
printf("\n you guess right,Congretulations!");/*游戲成功則提示祝賀信息*/
}
else
{
printf("\n You got it in %d times.\n",count);
printf("\n I bet you can do it better!");/*游戲失敗則提示鼓勵信息*/
}
printf("\n NEXT?(Y/N):");/*選擇是否重新游戲*/
scanf("%c",&yes);
}
}
2.
#include <stdio.h>
void main()
{
int gj, mj, xj, t1, t2;
for (gj=1; gj<=20; gj++)
{
for (mj=1; mj<34; mj++)
{
xj=100-gj-mj;
t1=xj%3;
t2=5*gj+3*mj+xj/3;
if (t1==0&&t2==100)
printf("gj=%d,mj=%d,xj=%d\n",gj,mj,xj);
}
}
}
3.
/* (a part of parser)
simple integer arithmetic calculator
<exp> -> <term>{<addop><term>}
<addop> -> + | -
<term> -> <factor> { <mulop> <factor> }
<mulop> -> * | /
<factor> -> (<exp>) | Number
see( page 12 of textbook )
Inputs a line of text from array
Outputs "Error" or the result.
*/
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
char token;
char array[50]="";
int pos=0;
char string[50]="";
int exp(void);
int term(void);
int factor(void);
bool isnumber(char ch)
{
if(ch>=48 && ch<=57)
return(true);
else return(false);
}
int CharToInt(char ch)
{
int temp = 0;
while((ch >= 48)&&(ch <= 57))
{
temp = temp*10+(ch-48);
ch = GetNextChar();
}
return temp;
}
void Error(char ch,int type)
{
if(type==0)
{
cout<<"Error: Missing symbol "<<ch<<endl;
getch();
}
else if(type==1)
{
cout<<"Error: "<<"'"<<ch<<"'"<<" is not number"<<endl;
getch();
}
else{printf("Error: '%c' is unwanted !\n",token);getch();}
exit(1);
}
char GetNextChar()
{
return(array[pos++]);
}
void Match(char shouldtoken)
{
if(token==shouldtoken)
token=GetNextChar();
else Error(shouldtoken,0);
}
void ReadTextFile(char str[])
{
FILE *fp;
char ch;
int i=0;
if((fp=fopen("text.txt","r"))==NULL)
{
printf("the file text.txt can not open!\n");
getch();
exit(1);
}
ch=fgetc(fp);
while(ch!=EOF)
{
str[i++]=ch;
ch=fgetc(fp);
}
strcpy(string,str);
str[i]='.';
fclose(fp);
}
//***********************************************************8
void main()
{
ReadTextFile(array);
int result;
token=GetNextChar();
result=exp();
if(token=='.')
printf("\n\n\ %s = %d\n\n",string,result);
else Error(token,2);
cout<<"input any key to exit....."<<endl;
getch();
}
int exp(void)
{
int temp=term();
while((token=='+')||(token=='-'))
switch(token)
{
case '+':
Match('+');
temp+=term();
break;
case '-':
Match('-');
temp-=term();
break;
default:
break;
}
return(temp);
}
int term(void)
{
int temp=factor();
while((token=='*')||(token=='/'))
switch(token)
{
case '*':
Match('*');
temp*=factor();
break;
case '/':
Match('/');
temp/=factor();
break;
default:break;
}
return(temp);
}
int factor(void)
{
int temp;
if(token=='(')
{
Match('(');
temp=exp();
Match(')');
}
else if(isnumber(token))
{
temp=CharToInt(token);
token=GetNextChar();
}
else Error(token,1);
return(temp);
}
4.
#include <stdio.h>
int main(void)
{
int a,b,c;
for(a=1;a<=9;a++)
for(b=0;b<=9;b++)
for(c=0;c<=9;c++)
if(100*a+10*b+c==a*a*a+b*b*b+c*c*c)
printf("%d%d%d\n",a,b,c);
return 0;
}
5.
int binarysearch(int a[],int x,int n)
{
int left,right,middle;
left=0;
right=n-1;
while(left<=right)
{
middle=(left+right)/2;
if(x==a[middle])
return middle;
if(x>a[middle])
left=middle+1;
else right=middle-1;
}
return -1;
}
8.
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* a, const void* b)
{
return (int)(*(char*)b - *(char*)a);
}
int sort(int n)
{
char buf[8];
sprintf(buf, "%d", n);
qsort(buf, 5, 1, cmp);
return atoi(buf);
}
int main(void)
{
int n;
scanf("%d", &n);
if(9999 < n && n < 100000)
printf("%d\n", sort(n));
return 0;
}
9.
int fun(int p[m][N],int m,int N)//m為行數,n為列數
{
int sum = 0;
for(int i=0;i<m;i++)
sum += p[m][0];
for(int j=0;j<m;j++)
sum += p[m][n-1];
for(int k=1;k<m-1;k++)
sum += p[0][k];
for(int k=1;k<m-1;k++)
sum += p[m-1][k];
return sum;
}
10.
char[] substr(char s[],int n1,int n2){
char ret[255];int i = 0;
for(;i<n2;i++) ret[i] = s[n1+i];
ret[i++] = '\0';
return ret;
}
⑧ C語言如何用代碼打出星星,如下
既然你這么急,我還是答一下吧,原圖沒法輸出,類似的可以實現,,你看哪個最像原圖就寫哪個吧:
圖形1:
#include <stdio.h>
int main(void)
{
int i,j;
for(i=1;i<=7;i++)
{
for(j=7-i;j--;) printf(" ");
for(j=i;j--;) printf(" *");
printf(" ");
}
return 0;
}
⑨ 怎樣給女朋友發早安
打開微信或者QQ,打「早安」兩個字,然後點擊發送,或者你可以選擇語音,發語音跟她說早安,你還可以發發一個你自己拍的視頻,跟她說早安。
⑩ C語言中的「不晚安」是什麼意思急急在線等……
不晚安看做一個object,他的語義我猜是「早安」,「早安」的非是「不早安」,是晚安?