首页 > 电脑 > 求编写一段程序

求编写一段程序

电脑 2022-09-03

求帮忙用C语言编写一段简单的程序,好的话我再加分

水仙花数 #include void main() { int i,a,b,c; printf("请输入一个三位数:"); scanf("%d",&i); if(i<100||i>999) printf("data error"); else { a=i/100; b=(i-a*100)/10; c=(i-a*100-b*10); if(a*a*a+b*b*b+c*c*c==i) printf("Y"); else printf("N"); } printf("\n"); } 成绩等级(switch) #include void main() { float

C语言编程,编写一段程序

#include"stdio.h"

intmain()

{

inti,n;

printf("请输入:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

if(i%3==0&&i%5==0&&i%7==0) /*能同时被3,5,7整除*/

printf("%d",i);

}

}

编写一段程序,求两个整数123和456的和,差,积与商,并输出结果c语言

#include void main(int argc, char *argv[]) { int iNum1,iNum2; printf("请输入二个数:\n"); scanf("%d %d",&iNum1,&iNum2); printf("%d+%d=%d\n",iNum1,iNum2,iNum1+iNum2); printf("%d-%d=%d\n",iNum1,iNum2,iNum1-iNum2); printf("%d*%d=%d\n",iNum1,iNum2,iNum1*iNum2); printf("%d/%d=%d\n",iNum1,iNum2,iNum1*iN

编写一段程序

#include using namespace std; int main () {long int num; int indiv,ten,hundred,thousand,ten_thousand,place; /*分别代表个位,十位,百位,千位,万位和位数*/ cout<<"enter an integer(0~99999):"; cin>>num; if (num>9999) place=5; else if (num>999) place=4; else if (num>99) place=3; else if (num>9) place=2; else pla

求编写一段程序,按下第一个按钮,数码管显示1,第二个显示2,第三个显示3

uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};//七段码 uchar flag=0; void main() { while(1){ if(key1==0)//按键1按下 { delayms(20); if(key1==0){while(key1==0);flag=1;} } if(key2==0)//按键2按下 { delayms(20); if(key2==0){while(key2==0);flag=2;} } if(ke

标签:信息技术 编程 编程语言 CC++ 程序

大明白知识网 Copyright © 2020-2022 www.wangpan131.com. Some Rights Reserved. 京ICP备11019930号-18