c语言程序设计输入50个学生的名字输出的列数=行数×2

c语言程序设计输入50个学生的名字输出的列数=行数×2,第1张

#include<stdioh>

struct name{

char nam[10];

}n[50];

void main()

{

int i, j, m;

for (i = 0; i<50; i++)

{

printf("Please the number %d\n",i+1);

scanf_s("%s", &n[i]nam,10);

getchar();

}

printf("The result is:");

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

{

for (j = 1; j<=10; j++)

{

m = ij - 1;

printf("%s\t",n[m]nam);

}

printf("\n");

}

}

代码转换

一、 实验目的:

熟悉C8051单片机常用代码之间的转换方法。

二、 实验任务:

1. 设计并调试一个程序,将片内20H单元中8位无符号二进制数转化为BCD码,结果存入以30H开始的单元中。

2. 设计并调试一个程序,将片内以20H开始的单元中的4字节无符号二进制数转化为BCD码,结果存入以30H开始的单元中,低位字节在低地址端。

三、 实验主程序及程序解读:

1. #include <c8051f020h>

void main (void)

{ unsigned char p1;

unsigned char p2;

unsigned char hundred,ten,one;

p1=0x20; //p1指针指向片内20H

p2=0x30; //p2指针指向片内20H

p1=0xef;

hundred=p1/100; //片内20H单元中8位无符号二进制数 ten=(p1-hundred100)/10; //转化为BCD码

one=p1%10;

p2=one; //转化结果存入以30H开始的单元中

(p2+1)=ten;

(p2+2)=hundred;}

2.#include <c8051f020h>

void main (void)

{unsigned long p1;

unsigned char p2;

unsigned long a;

p1=0x20; // 20H

p2=0x30; // 30H

a=0x12341234;

p1=a;

for(;;a!=0)

{

p2=a%10; // 片内以20H开始的单元中的4字节

a=a/10; // 无符号二进制数转化为BCD码

p2++; //转化结果存入以30H开始的单元中

}

}

我在TC上调试通过了,不过时间好像过了额

/开发环境:turbo c 20模拟时钟转动程序代码/

#include"graphicsh"

#include"mathh"

#include"dosh"

#define pi 31415926

#define X(a,b,c) x=acos(bcpi/180-pi/2)+300

#define Y(a,b,c) y=asin(bcpi/180-pi/2)+240

#define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y)

void init() /划时钟边框函数/

{

int i,l,x1,x2,y1,y2;

setbkcolor(1);

circle(300,240,200);

circle(300,240,205);

circle(300,240,5);

for(i=0;i<60;i++) /划钟点上的短线/

{

if(i%5==0)

l=15;

else

l=5;

x1=200sin(i6pi/180)+300;

y1=200cos(i6pi/180)+240;

x2=(200-l)sin(i6pi/180)+300;

y2=(200-l)cos(i6pi/180)+240;

line(x1,y1,x2,y2);

}

}

main()

{

int x,y,i,k=1;

int gdriver=9,gmode=2;

unsigned char h,m,s;

int o,p,q;

float n;

struct time t[1];

struct date d[1];

initgraph(&gdriver,&gmode,"c:\\tc");

initgraph(&gdriver,&gmode,"c:\\tc");

for(i=0;i<=6;i++)

{

settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /控制输出字符的字体,方向,大小/

cleardevice();

#include <graphicsh>

#include <mathh>

#include <stdlibh>

#include <dosh>

#define KEY_ESC 0x01

#define KEY_SPACE 0x39

#define KEY_UP 0x48

#define KEY_LEFT 0x4b

#define KEY_RIGHT 0x4d

#define KEY_DOWN 0x50

int gamespeed=1200;/自己改游戏的速度/

int speed;/飞碟移动速度/

int col;/中心坐标/

int score=0;/得分/

char key_state[128],key_pressed[128];/键盘 *** 作用的变量/

void Init();/初始/

void Close();/关闭/

void PlayGame();/游戏过程/

void PrScore();/输出成绩/

void DrawM(int x,int y,int color);/画瞄准器/

void Win();/输出最后结果/

int GetKey(int ScanCode);/这里开始都是按键函数/

void interrupt far (OldInt9Handler)();

void far interrupt NewInt9();

void InstallKeyboard();

void ShutDownKeyboard();

DrawFly(int x,int y,int color);/画飞碟/

void main(void)

{

Init();

PlayGame();

Close();

}

void PrScore()/输出成绩/

{

char s[10];

setfillstyle(SOLID_FILL,BLACK);

bar(30,0,100,50);

setcolor(6);

settextstyle(0,0,2);

sprintf(s,"%d",score);

outtextxy(30,20,s);

}

void DrawM(int x,int y,int color)/画瞄准器/

{

setcolor(color);

rectangle(x-10,y-10,x+10,y+10);

line(x-8,y,x+8,y);

line(x,y-8,x,y+8);

}

void Win()/输出最后结果/

{

settextstyle(0,0,4);

setcolor(RED);

if(score>18)

outtextxy(200,200,"VERY GOOD");

else if(score>10)

outtextxy(250,200,"GOOD");

else

outtextxy(250,200,"~@_@~");

}

void PlayGame()/游戏过程/

{

float x,y;/飞碟的坐标/

int mx,my;

int i,num=0;

for(i=40;i<640;i+=30)

DrawFly(i,65,WHITE);

mx=my=300;

setcolor(15);

line(0,80,640,80);

randomize();

while(num<20)

{

PrScore();/输出成绩/

col=random(10);/中心坐标随机/

col=col20+200;

speed=2+random(2);/飞碟速度随机/

for(x=-250;x<=250;x+=speed)/飞碟移动全过程/

{

y=pow((x/10),2)+200;/求y坐标/

DrawFly(x,y,WHITE);

DrawM(mx,my,YELLOW);

delay(gamespeed);/间隔/

DrawM(mx,my,BLACK);

DrawFly(x,y,BLACK);

if(GetKey(KEY_ESC))/结束游戏/

break;

if(GetKey(KEY_LEFT))

mx-=4;

if(GetKey(KEY_RIGHT))

mx+=4;

if(GetKey(KEY_DOWN))

my+=4;

if(GetKey(KEY_UP)&&my>100)

my-=4;

if(GetKey(KEY_SPACE))/发子d/

{

if(((x+col+10)>=(mx-2)&&x<=(mx+2))&&(y>=(my-2)&&y<=(my+2)))/这里控制精确度/

{

score++;

DrawFly(x,y,BLACK);

DrawM(mx,my,YELLOW);

PrScore();

DrawM(mx,my,BLACK);

break;

}

}

if(y>490&&col+x>col)/自动消失/

break;

}

if(y<490)

{

setcolor(RED);

line(40+num30-10,55,40+num30+10,75);

line(40+num30-10,75,40+num30+10,55);

}

num++;

if(GetKey(KEY_ESC))/结束游戏/

break;

}

Win();

while(1)

{

if(GetKey(KEY_ESC))

break;

}

}

void Init()/初始/

{ int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\tc");

cleardevice();

InstallKeyboard();

}

void Close()/关闭/

{

ShutDownKeyboard();

closegraph();

}

DrawFly(int x,int y,int color)/画飞碟/

{

setcolor(BLACK);

setfillstyle(SOLID_FILL,color);

fillellipse(col+x,y,10,6);

}

void far interrupt NewInt9(void)

{

unsigned char ScanCode,temp;

ScanCode=inportb(0x60);

temp=inportb(0x61);

outportb(0x61,temp | 0x80);

outportb(0x61,temp & 0x7f);

if(ScanCode&0x80)

{

ScanCode&=0x7f;

key_state[ScanCode]=0;

}

else

{

key_state[ScanCode]=1;

key_pressed[ScanCode]=1;

}

outportb(0x20,0x20);

}

void InstallKeyboard(void)

{

int i;

for(i=0;i<128;i++)

key_state[i]=key_pressed[i]=0;

OldInt9Handler=getvect(9); /中断向量值/

setvect(9,NewInt9); /中断程序NewInt9地址存入指定的中断向量表中INT 09H/

}

void ShutDownKeyboard(void)

{

setvect(9,OldInt9Handler);

}

int GetKey(int ScanCode)

{

int res;

res=key_state[ScanCode]|key_pressed[ScanCode];

key_pressed[ScanCode]=0;

return res;

}

1。加很多头文件

#include <stdioh>

#include <mathh>什么的。多找点

2。printf多写几句。

首先可以友好的提示输入:

printf("输入XXXX,回车输入")

其次,可以输出结果多整上几行。很有用的!

3。把运算全部放到函数里面。这样声明占一行,实现好几行,绝对ok

4。如果可以,你可以加上注释。瞎罗嗦,很管用!

main(){

int i,n=0;

for(i=1;i<51;i++){

printf("%d\t",i);

n++;

if(n==5){

n=0;

printf("\n");

}

}

}

我这不知道合适不合适!

以上就是关于c语言程序设计输入50个学生的名字输出的列数=行数×2全部的内容,包括:c语言程序设计输入50个学生的名字输出的列数=行数×2、c语言程序编写、跪求C语言程序设计编程,大概需要100行等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9337480.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存