山东理工acm非专业-顺序结构

C语言实验——用*号输出字母C的图案
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
请编程序用*号输出字母C:
*****
*
*
*
*****
Input
无输入数据。
Output
输出用*号描述的字母C:
*****
*
*
*
*****
Example Input

Example Output

*****
*
*
*
*****

Hint
Author

wy

--------------------------------------------------------------------------------我是邪恶的分割线-------------------------------------

#include<stdio.h>
int main()
{
printf("*****\n*\n*\n*\n*****");
return 0;
}

--------------------------------------------------------------------------------我是邪恶的分割线-------------------------------------

C语言实验——打印图形
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
请编写程序,打印如下图形:
Input
无输入数据。
Output
输出如下图形:


说明:在上面的图形中,*号共30个。字符串Very good!的首字母前面有10个空格,上下分别有一空行。
Example Input

Example Output

******************************

          Very good!          

******************************

Hint
Author
wy

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
printf("******************************\n\n          Very good!\n\n******************************");
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

C语言实验——求两个整数之和
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
求两个整数之和,不从键盘输入数据,直接使用赋值语句(a=123;b=456)输入数据,然后计算两个整数之和输出。
Input
无输入数据。
Output
输出a和b之和。
Example Input

Example Output

sum is 579

Hint
Author
wy

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
int a,b,c
a=123;
b=456;
c=a+b;
printf("sum is %d",c);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

A+B Problem
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description

Calculate a+b.
Input

Two integer a,b (0<=a,b<=10).
Output

Output a+b.
Example Input

1 2

Example Output

3

Hint

问:怎样输入输出?

答:你的程序应该从标准输入(stdin)中读取数据,而将结果写到标准输出(stdout)。比如,在C语言中你可以使用“scanf”,在C++语言中则可以使用“cin”来输入;输出可以使用C语言的“printf”或者C++语言的“cout”。

注意:不要向标准输出写入题目要求输出结果之外的其他数据,否则你会被判为“Wrong Answer”,即错误的运行结果。

你的程序也不能试图读或写任何文件,否则你可能被判为“Runtime Error”(运行时错误)或“Wrong Answer”(错误结果)。

下面是这道题的一个C++或者G++的程序。

#include < iostream >      //请注意include的使用,如果使用#include 在G++编译器上将出现“Compile Error”
using namespace std;
int main()
{
     int a,b;
     cin >> a >> b;
     cout << a+b << endl;
     return 0;
}

注意:对于GCC或者G++,main()函数的返回值必须是int型,否则可能导致“Compile Error”,即编译错误。

下面是这道题的一个C或者GCC的程序。

#include < stdio.h >
int main()
{
     int a,b;
     scanf("%d %d",&a, &b);
     printf("%d\n",a+b);
     return 0;
}
Author

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d",&a, &b);
c=a+b;
printf("%d\n",c);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

C语言实验——计算A+B(顺序结构)
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
这是一道在各个ACM训练网站上最基本的题目,一般都是他们的第一道题,来让大家熟悉在线评测系统的环境!
从键盘上输入两个整数,然后计算他们的和,并把他们的和打印出来。
Input
从键盘上输入两个整数,这两个整数在同一行上!
Output
在这两个整数的下面一行是输出这两个整数的和!
Example Input

2 3

Example Output

5

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d",&a, &b);
c=a+b;
printf("%d\n",c);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

C语言实验——交换两个整数的值(顺序结构)
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
交换两个变量的值,由终端输入两个整数给变量x、y,然后交换x和y的值后,输出x和y。
Input
从键盘输入两个整数变量x和y;
Output
在交换x、y的值后将x和y输出!
Example Input

4 6

Example Output

6 4

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
int x,y,z;
scanf("%d %d",&x, &y);
z=x;
x=y;
y=z;
printf("%d %d",x,y);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

C语言实验——逆置正整数
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
输入一个三位正整数,将它反向输出。
Input
3位正整数。
Output
逆置后的正整数。
Example Input

123

Example Output

321

Hint
注意130逆置后是31
Author
crq

-------------------------------------我是邪恶的分割线-----------------------------------------

#include<stdio.h>
int main()
{
int n,N;
scanf("%d",&n);
N=n%10*100+n%100/10*10+n/100;
printf("%d\n",N);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

//C语言实验——买糖果

#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d",&a);
b=a/0.3;
c=(a*10)%3;
printf("%d %d",b,c);
return 0;
}

-------------------------------------我是邪恶的分割线-----------------------------------------

///三个整数和、积与平均值

#include<stdio.h>
int main()
{
float a,b,c,add,mul,ave;
int d,e;
scanf("%f %f %f",&a,&b,&c);
add=a+b+c;
mul=a*b*c;
ave=(a+b+c)/3;
d=(int)add;
e=(int)mul;
printf("%d %d %.2f",d,e,ave);
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------

//格式化输出[常量练习]

#include<stdio.h>
int main()
{
printf("100\nA\n3.140000");
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------

.圆柱体计算.

#include<stdio.h>
#define PI 3.1415926
int main()
{
int h,r;
float C,s1,s2,V;
scanf("%d %d",&r,&h);
C=2*PI*r;
s1=PI*r*r;
s2=C*h;
V=s1*h;
printf("%.2f %.2f %.2f %.2f",C,s1,s2,V);
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------

温度转换

#include<stdio.h>
int main()
{
float a,b,c;
scanf("%f",&a);
c=5.0*(a-32);
b=c/9;
printf("%.2f",b);
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------

单个字符输入和输出[顺序结构]

#include<stdio.h>
int main()
{
char a;
a=getchar();
putchar(a);
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------

转换字母[顺序结构]

#include<stdio.h>
int main()
{
char a,b;
scanf("%c",&a);
b=a-32;
printf("%c",b);
return 0;
}

------------------------------------我是邪恶的分割线-----------------------------------------



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值