A. c語言打出蠟燭
是笑臉的,可能是編譯器問題,也許是突然間的問題,你多運行幾次。或者升級一下Dev吧,我用的都是5.4.1的了
B. 有一個聖誕快樂的程序據說是用C語言寫的,我想把它改成生日快樂的,跪求原代碼~謝謝各位
#include"stdio.h"
#include <string.h>
intmain(void){
chara[]="Iwishyouahappybirthday!Iwishyouahappybirthday!",m[4],i;
printf("\n\n\n");
printf("%*.*s\n",58,21,"_*=__=*_");
printf("%*.*s\n",61,25,"Wishyourbirthday!");
printf("%*.*s\n",63,29,"Iwishyouahappybirthday!");
printf("%*.*s\n",65,33,a);
printf("%*.*s\n",66,35,a);
printf("%*.*s\n",66,35,a);
printf("%*.*s\n",65,33,a);
printf("%*.*s\n",64,31,a);
printf("%*.*s\n",63,29,a);
printf("%*.*s\n",61,25,a);
printf("%*.*s\n",59,21,a);
printf("%*.*s\n",57,17,a);
printf("%*.*s\n",55,13,a);
printf("%*.*s\n",53,9,a);
printf("%*.*s\n",51,5,a);
printf("%*.*s\n",50,3,a);
printf("%*.*s\n",49,1,a);
return0;
}
(2)用c語言編寫小明吹蠟燭擴展閱讀
或者:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#defineI20
#defineR340
intmain()
{
system("modeconcols=80lines=60");
system("title向你致以最誠摯的祝福!");
chardata[200][60]={{"祝你生日快樂!祝你生日快樂!"},{"\nHappybirthdaytoyou!\n"},{"Happybirthdaymydearfriend!\n"},
{"在你面前的台里本,總有一天是很獨特!\n"},{"雖然你和我,沒辦法選,來到世界的某刻。\n"},{"天氣寒冷,又或炎熱,又或者什麼血型和星座!\n"},
{"每年這刻,我對自己說,有生的日子要更快樂!\n"},{"天氣寒冷,又或炎熱,又或者什麼血型和星座!\n"},{"每年這刻,我對自己說,有生的日子要更快樂!\n"},
{"爸爸媽媽辛苦了!謝謝你們為我付出太多!\n"},{"生日祝福,吹滅蠟燭,我要我自己不許哭。\n"},{"長大了一歲變得靠譜,繼續走自己的旅程!\n"},
{"又到這一個時刻,幸福的花火,手機祝福收到很多很多。\n"},{"看到最後一條來自你,寫著讓我感動的話語。\n"},{"親愛的朋友要經常聯絡,我們一起來唱這首歌!\n"},
{"祝你生日快樂額!我們一起快樂!\n"}
};
intsign=0;
inti,j,e;
inta;
longtime;
for(i=1,a=I;i<I/2;i++,a--)
{
for(j=(int) ( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--)
printf("");
for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)
printf("\3");
for(j=(int)
( 2*( I-sqrt(I*I-(a-i)*(a-i)) ) );j>0;j--)
printf("");
for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)
printf("\3");
printf("\n");
}
for(i=1;i<80;i++)
{
if(i==25)
{
printf("======祝,生日快樂。======");
i+=30;
}
printf("\3");
}
printf("\n");
for(i=1;i<=R/2;i++)
{
if(i%2||i%3)
continue;
for(j=(int) ( R-sqrt(R*R-i*i) );j>0;j--)
printf("");
for(e=1;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++)
printf("\3");
printf("\n");
}
for(;;)
{
system("colora");
for(time=0;time<99999999;time++); system("color b");
for(time=0;time<99999999;time++); system("color c");
for(time=0;time<99999999;time++); system("color d");
for(time=0;time<99999999;time++); system("color e");
for(time=0;time<99999999;time++); system("color f");
for(time=0;time<99999999;time++);
system("color 0"); for(time=0;time<99999999;time++);
system("color 1"); for(time=0;time<99999999;time++);
system("color 2"); for(time=0;time<99999999;time++);
system("color 3"); for(time=0;time<99999999;time++);
system("color4");
for(time=0;time<99999999;time++); system("color 5");
for(time=0;time<99999999;time++); system("color 6");
for(time=0;time<99999999;time++); system("color 7");
for(time=0;time<99999999;time++); system("color 8");
for(time=0;time<99999999;time++); system("color 9");
for(time=0;time<99999999;time++); system("color ab");
for(time=0;time<99999999;time++); system("color ac");
for(time=0;time<99999999;time++); system("color ad");
for(time=0;time<99999999;time++); system("color ae");
for(time=0;time<99999999;time++); system("color af");
for(time=0;time<99999999;time++);
printf("%s",data[sign]);
sign++;
}
return0;
}
C. 用C語言編寫下列程序
#include <stdio.h>
int main()
{
int a=1,b=2,c=3,t;
t=a;
a=b;
b=t;
t=b;
b=c;
c=t;
printf("a=%d,b=%d,c=%d ",a,b,c);
return 0;
}
D. 有a根蠟燭,每根蠟燭可以點亮1分鍾。然而可將b根用完的蠟燭搓成一根新的蠟燭。問蠟燭能燃燒多少分鍾呢
僅供參考:
#include "stdio.h"
int firetime(int a,int b); //計算蠟燭燃燒時間
void main()
{
int a,b;
int sum;
printf("請輸入蠟燭根數:");
scanf("%d",&a);
printf("多少根燒完的蠟燭可以搓成1根新蠟燭:");
scanf("%d",&b);
sum = firetime(a,b);
printf("這些蠟燭可以燒%d分鍾。\n",sum);
}
int firetime(int a,int b)
{
int time_sum = 0; //燃燒時間
int lazhu_new =a; //蠟燭根數
int lazhu_old =0; //燒完的蠟燭
while(1)
{
time_sum += lazhu_new; //蠟燭燃燒過程
lazhu_old += lazhu_new; //蠟燭燒完,當前燒完的蠟燭的總數
if(lazhu_old < b) //如果燒完的蠟燭不夠搓成一根,則退出循環
{
break;
}
lazhu_new = lazhu_old/b; //將b跟燒完的蠟燭搓成一根新的蠟燭
lazhu_old -= lazhu_new * b; //還剩下的燒完蠟燭數
}
return time_sum;
}
E. 如何用c語言實現蠟燭點燃這一過程
這個問題的核心不是語言,而是對這一過程的數學建模,抽象出了合適的模型,再用程序來實現就簡單了。
F. 用簡單的C語言寫出如下題目
按照題目要求以及輸入輸出格式,程序代碼如下,由於輸出樣式,一些不符合輸出樣式的輸出語句使用//作為注釋,如果需要格式,去掉//即可
#include<stdio.h>
#include<math.h>
structmonster
{
intx;
inty;
intz;
};
structskill
{
inta;
intb;
intr;
inth;
};
intmain()
{
intn,i,mk=0;;
monstera[10];
skills;
//printf("請輸入怪物數量: ");
scanf("%d",&n);
while(n)
{
i=0;
mk=0;
//printf("請輸入怪物信息: ");
while(i<n)
{
scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
i++;
}
//printf("請輸入技能參數: ");
scanf("%d%d%d%d",&s.a,&s.b,&s.r,&s.h);
i=0;
while(i<n)
{
if(pow((a[i].x-s.a),2)+pow((a[i].y-s.b),2)<=pow(s.r,2)&&a[i].z<=s.h)
{
mk++;
}
i++;
}
//printf("本次技能消滅怪物數目:");
printf("%d ",mk);
scanf("%d",&n);
}
return0;
}
如果對您有幫助,望採納。
G. 用c語言編寫這道題的程序
#include<stdio.h>
int main()
{
int n,sum=0,t=0;
while(scanf("%d",&n),n!=0)
{
if(n>0)
{
sum+=n;
t++;
}
printf("%d %d\n",sum,t);
return 0;
}
H. C語言編程
首先是scanf讀入double要用%lf
其次if else嵌套太多,一定要用花括弧{},避免自己搞混
再次,變數名要有意義些
#include<stdio.h>
//#include"genlib.h"
//#include"simpio.h"
intmain(void){
intloopCount,i;//後面這些變數沒有被用到啊m,n,s[10];
doubleopen,close,max,min;//給變數起有意義的名字
doubleupper,lower;//箱體的上下邊界
scanf("%d",&loopCount);
for(i=0;i<loopCount;i++){//請遵循c語言從0開始的慣例
scanf("%lf%lf%lf%lf",&open,&close,&max,&min);
//判斷箱體的上下邊界
if(open>close){
upper=open;
lower=close;
}else{
upper=close;
lower=open;
}
//判斷有無影線
if((max<=upper)&&(min>=lower)){
printf("無");
}else{
printf("有");
if(max>upper){
printf("上");
}
if(min<lower){
printf("下");
}
}
printf("影線的");
//判斷是"空心紅","實心藍白"還是"十字紅"
if(open<close){
printf("空心紅");
}else{
if(open>close){
printf("實心藍白");
}else{//open==close
printf("十字紅");
}
}
printf("蠟燭 ");
}
}