请高手们给我写几个小程序(最初级的)交作业,明天要交作业,多谢
3.
编一C程序,它能读入两个整数m与n,计算并输出m与n的绝对值的最大公约数及最小公倍数
解:源程序如下:
int
gys
(int
x,int
y)
{
int
j;
j=(x<y)?x:y;
for(;j>0;j--)
if(x%j==0&&y%j==0)
break;
else
continue;
return
(j);
}
int
gbs
(int
z,int
w)
{
int
i;
i=(z>w)?z:w;
for(;i<=z*w;i++)
if(i%z==0&&i%w==0)
break;
else
continue;
return
(i);
}
main()
{
int
m,n;
clrscr();
printf("input
n,m(n>0,m>0):");
scanf("%d%d",&n,&m);
printf("max
gys
is:%d
",gys(n,m));
printf("min
gbs
is:%d
",gbs(n,m));
}
终于有空帮你写了个!
其余的自己加油吧,你自己想了再做,不要一意味的提问,对你没好处,别人做的毕竟是别人的!
如果你老是什么事情都求别人,那么无法煅炼你的能力,在以后的的找工作中你会吃亏的!
我们都在不断赶路,只是没有人愿意认输!
1.河里的孩子正在喊救命,让我们帮他出来。
. the children are crying for help in the river, Let us put him out
2.你的同桌是什么样的?
what kind of your deskmate is
-------很友好又很乐于助人。
- - - -very friendly and helpful.
3.他的家什么样子?
3. what does his home looks like?
-------小而干净。
- - - -small and clean.
4.她需要一些帮助,让他帮她打扫卫生吧。
4. She needs some help, let him help her to clean it.
5.别担心你的学习,我会帮你学科学的
5. Don't worry about your study, I will help you with your science
翻译完毕.........差不多就是初一的程度....望采纳 祝你学习进步
#include <stdio.h>
void main ()
{
int value = 0;
while (value <= 100)
{
printf("%d\n", value);
value++;
}
}
//02 3_MSGS.C
#include <stdio.h>
void main ()
{
printf ("1001 ");
printf ("C and C++ ");
printf ("Tips!");
}
//03 BIT_AND.C
#include <stdio.h>
void main ()
{
printf("0 & 0 is %d\n", 0 & 0);
printf("0 & 1 is %d\n", 0 & 1);
printf("1 & 1 is %d\n", 1 & 1);
printf("1 & 2 is %d\n", 1 & 2);
printf("15 & 127 is %d\n", 15 & 127);
}
//04 BIT_INV.C
#include <stdio.h>
void main ()
{
int value = 0xFF;
printf("The inverse of %X is %X\n", value, ~value);
}
//05 BIT_OR.C
#include <stdio.h>
void main ()
{
printf("0 | 0 is %d\n", 0 | 0);
printf("0 | 1 is %d\n", 0 | 1);
printf("1 | 1 is %d\n", 1 | 1);
printf("1 | 2 is %d\n", 1 | 2);
printf("128 | 127 is %d\n", 128 | 127);
}
//06 BIT_XOR.C
#include <stdio.h>
void main ()
{
printf("0 ^ 0 is %d\n", 0 ^ 0);
printf("0 ^ 1 is %d\n", 0 ^ 1);
printf("1 ^ 1 is %d\n", 1 ^ 1);
printf("1 ^ 2 is %d\n", 1 ^ 2);
printf("15 ^ 127 is %d\n", 15 ^ 127);
}
//07 CHAR_OUT.C
#include <stdio.h>
void main ()
{
printf("The letter is %c\n", 'A');
printf("The letter is %c\n", 65);
}
//08 COMMENT.C
/* Purpose: Illustrates the use of comments in a C program.*/
#include <stdio.h>
void main ()
{
printf ("1001 C & C++ Tips!"); /* Display a message*/
}
//09 CON_VOWL.C
#include <stdio.h>
void main()
{
char letter;
int vowel_count = 0;
int consonant_count = 0;
for (letter = 'A'; letter <= 'Z'; letter++)
switch (letter) {
case 'A':
case 'E':
case 'I':
case 'O':
case 'U': vowel_count++;
break;
default: consonant_count++;
};
printf("The number of vowels is %d\n", vowel_count);
printf("The number of vowels is %d\n", consonant_count);
}
//10 DO_MENU.C
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
void main()
{
char letter;
do {
printf("A Display directory listing\n");
printf("B Display disk information\n");
printf("C Change system date\n");
printf("Q Quit\n");
printf("Choice: ");
letter = getch();
letter = toupper(letter);
if (letter == 'A')
system("DIR");
else if (letter == 'B')
system("CHKDSK");
else if (letter == 'C')
system("DATE");
}
while (letter != 'Q');
}
//11 EQL_NEQL.C
#include <stdio.h>
void main ()
{
int age = 21;
int height = 73;
if (age == 21)
printf("User's age is 21\n");
if (age != 21)
printf("User's age is not 21\n");
if (height == 73)
printf("User's height is 73\n");
if (height != 73)
printf("User's height is not 73\n");
}
//12 EXP_FMT.C
#include <stdio.h>
void main ()
{
float value = 1.23456;
printf ("%12.1e\n", value);
printf ("%12.3e\n", value);
printf ("%12.5e\n", value);
}
//13 EXP_OUT.C
#include <stdio.h>
void main ()
{
float pi = 3.14159;
float radius = 2.0031;
printf("The circle's area is %e\n", 2 * pi * radius);
printf("The circle's area is %E\n", 2 * pi * radius);
}
//14 FLOATOUT.C
#include <stdio.h>
void main ()
{
float price = 525.75;
float sales_tax = 0.06;
printf("The item cost is %f\n", price);
printf("Sales tax on the item is %f\n", price * sales_tax);
}
//15 FLT_FMT.C
#include <stdio.h>
void main ()
{
float value = 1.23456;
printf ("%8.1f\n", value);
printf ("%8.3f\n", value);
printf ("%8.5f\n", value);
}
//16 FLT_PT.C
#include <stdio.h>
void main ()
{
printf("Displaying 0.1234 yields %g\n", 0.1234);
printf("Displaying 0.00001234 yields %g\n", 0.00001234);
}
//17 FOR_2VAR.C
#include <stdio.h>
void main()
{
int i, j;
for (i = 0, j = 100; i <= 100; i++, j++)
printf("i = %d j = %d\n", i, j);
}
//18 FOR_DIFF.C
#include <stdio.h>
void main ()
{
int counter;
for (counter = -100; counter <= 100; counter += 5)
printf("%d ", counter);
printf("\nStarting second loop\n");
for (counter = 100; counter >= -100; counter -= 25)
printf("%d ", counter);
}
//19 FOR_DOWN.C
#include <stdio.h>
void main ()
{
int counter;
for (counter = 5; counter >= 1; counter--)
printf("%d ", counter);
printf("\nStarting second loop\n");
for (counter = 10; counter >= 1; counter--)
printf("%d ", counter);
printf("\nStarting third loop\n");
for (counter = 0; counter >= 1; counter--)
printf("%d ", counter);
}
//20 FOR_MORE.C
#include <stdio.h>
void main ()
{
char letter;
float percent;
for (letter = 'A'; letter <= 'Z'; letter++)
putchar(letter);
for (letter = 'z'; letter >= 'a'; letter--)
putchar(letter);
putchar('\n');
for (percent = 0.0; percent < 1.0; percent += 0.1)
printf("%3.1f\n", percent);
}
还有很多~
去"编程中国"的论坛里面看看,里面关于各种语言都有比较详细的例题分析,总结的非常好.
www.bc-cn.net
相关视频
想做个简单的Delphi记事本小程序,请高手们帮帮忙教教我,给我一个完整的...
先做界面,总共三个窗体,再编写代码;代码如下:unit Unit1;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ComCtrls, Menus;type TForm1 = class(TForm)MainMenu1: TMainMenu;N1: TMenuItem;N2: TMenuItem;N3: TMenuItem;N4: T...
c语言编个小程序
本题的一个完整c程序如下,win-tc和Dev-c++下已调试通过。其中通用排序函数为void sort()include "stdio.h"include "stdlib.h"include "conio.h"include "string.h"define ROW 100 define COL 80 void sort();int main(){ int n,i;char s[ROW][COL+1];printf("Please input the number ...