C语言 homework(4)

#include <stdio.h>
int main(){
    int i,sum=0;
    i=1;
    while(i<=100)
    {
        sum+=i;
        i++;
    }
    printf("sum=%d\n",sum);
    return 0;
}
#include <stdio.h>
int main(){
    int i,sum=0;
    i=1;
    sum=0;
    do{
        sum+=i;
        i++;
    }while(i<=100);
    printf("sum=%d\n",sum);
    return 0;
#include <stdio.h>
int main(){
    int i,sum=0;
    sum=0;
    for(i=1;i<=100;i++)
        sum+=i;
    printf("sum=%d\n",sum);
    return 0;
  } 
#include <stdio.h>
int main()
{
    int i,sum=1,n;
    i=1;
    printf("请输入n的值:");
    scanf("%d",&n);
    while(i<=n)
    {
        sum=sum*i;
        i++;
    }
    printf("sum=%d\n",sum);
    return 0;
}
#include <stdio.h>
int main()
{
    int i,sum=1,n;
    i=1;
    printf("请输入n的值:");
    scanf("%d",&n);
    do
    {
        sum=sum*i;
        i++;
    }
    while(i<=n);
    printf("sum=%d\n",sum);
    return 0;
}
#include <stdio.h>
int main()
{
    int i,sum=1,n;
    printf("请输入n的值:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    sum=sum*1;
    printf("sum=%d\n",sum);
    return 0;
}
#include <stdio.h>
#include <math.h>
int main(){
    long int k,sum=1,sum1,sum2;
    do{
        sum+=k;
        k++;
    }while(k<=100);
    for(k=1;k<=50;k++)
        sum1=k*k;
    for(k=1;k<=10;k++)
        sum2=1/k;
    printf("总数为:%d\n",sum+sum1+sum2);
    return 0;
}

#include <stdio.h>
int main(){
    char c;
    int zm=0,sz=0,kg=0,qt=0;
    while((c=getchar())!=‘\n‘){
        if((c>=‘a‘ && c<=‘z‘) ||(c>=‘A‘ && c<=‘Z‘))
            zm++;
        if(c==‘ ‘)
            kg++;
        if(c>=‘0‘ &&c<=‘9‘)
            sz++;
        else
            qt++;
    }
    printf("字母个数:%d\n",zm);
    printf("空格个数:%d\n",kg);
    printf("数字个数:%d\n",sz);
    printf("其他字符个数:%d\n",qt);
} 

#include<stdio.h>
int main(){
    int a,b,m,n;
    printf("请输入正整数m和n:\n");
    scanf("%d%d",&a,&b);
    m=a;
    n=b;
    while(a!=b)
        if(a>b)
            a=a-b;
        else
            b=b-a;
    printf("最大公约数为:%d\n",a);
    printf("最小公倍数为:%d\n",m*n/a);
}

#include<stdio.h>
int main()
 {
    int a,b,c,z;
    for(a=1;a<=9;a++)
    for(b=0;b<=9;b++)
    for(c=0;c<=9;c++)
    {
        z=a*100+b*10+c;
        if(a*100+b*10+c==a*a*a+b*b*b+c*c*c)
        printf("水仙花数为:%d\n",z);
    }
    return 0;
 }

时间: 2024-10-12 23:57:19

C语言 homework(4)的相关文章

C 语言 homework(2)

<C语言程序设计>实验报告 学 号 160809215 姓 名 韩笑 专业.班 计科16-2班 学 期 2016-2017 第1学期 指导教师 黄俊莲 吴喆 实验地点 C区二层机房 机 器 号 上课时间 2016年 9 月 22 日 2 周 周四 1-4 节 截止时间 2016年 9 月 28 日 3 周 周三 12:00 实验任务清单 1. 实验2-1 输入3个数,并按由大到小的顺序输出. 2. 实验2-2 从键盘上输入x的值,并根据计算输出y的值 3. 实验2-3从键盘上输入一个字母,如果

UVa 12412 A Typical Homework(学生信息管理系统)

A Typical Homework(a.k.a Shi Xiong Bang Bang Mang) Hi, I am an undergraduate student in institute of foreign languages. As you know, C programming is a required course in our university, even if his/her major is far from computer science. I don't lik

C语言 cgi(2)

1Columbia Universitycs3157 – Advanced ProgrammingSummer 2014, Lab #3, 40 pointsJune 10, 2014This lab is due June 23rd 11:59 pm.• lab in C. We will be using Makefiles.• Don’t forget to FREE up any memory you request!!• Make sure you complete the relev

C语言 cgi(3)

1cs3157 – Advanced ProgrammingSummer 2014, Project 1, 150 pointsJune 17, 2014Follow these step-by-step instructions. This homework must be submitted electronically bySunday night July 6th, 11pm. Please start early, so we can help if you get stuck.In

C语言cgi(1)

1Columbia Universitycs3157 – Advanced ProgrammingSummer 2014, Lab #2, 60ish pointsJune 9, 2014Follow these step-by-step instructions. This lab must be submitted electronically by Monday June16th, 11:55 pm.The point of the labs is to teach and reinfor

C语言程序代写(qq:928900200)

1cs3157 – Advanced ProgrammingSummer 2014, Project 1, 150 pointsJune 17, 2014Follow these step-by-step instructions. This homework must be submitted electronically bySunday night July 6th, 11pm. Please start early, so we can help if you get stuck.In

TCP 、UDP网络编程作业代写、代写C 语言 TCP程序 Network Programming using C

TCP .UDP网络编程作业代写.代写C 语言 TCP程序Network Programming using COverview? This homework is due by 11:59:59 PM on Thursday, April 26, 2018.? This homework will count as 8% of your final course grade.? This homework is to be completed individually. Do not shar

hOmewOrk 第三单元 总结

hOmewOrk 第三单元 总结 JML理论基础梳理 JML是用于对Java程序进行规格化设计的一种表示语言. 1. 注释结构 JML表示规格的内容包含在注释之中.可以使用行注释和块注释.行注释的表示方式为 //@annotation ,块注释的方式为 /* @ annotation @*/ . 2. JML表达式 JML表达式是在基于JAVA语法基础上,新增了一些操作符和和原子表达式组成的. 2.1 原子表达式 \result表达式:表示方法执行后的返回值. \old( expr )表达式:用

ECON 331 - Homework

ECON 331 - Homework #1due in class October 2nd at 2.30pmLate homework will not be considered. Show detailed calculations and/or provide detailedexplanations to get full credit. Partial credit may be given.• Exercise 1. Show by recurrence that the fol