用c语言写小程序

用c语言写小程序,第1张

#include <iostream>

using namespace std

int _tmain(int argc, _TCHAR* argv[])

{

int a

cout<<"请输入数字凳颤"<<endl

cin>>a

int b=0

while(a)

{

b=a%10+10*b

a=a/10

}

cout<<州销b<<endl

system("pause"册粗游)

return 0

}

/*我链悉用c++做一下,你可以把输入输出自己转化一下*/

#include<iostream.h>

#define MaxSize 100

int data[MaxSize][MaxSize]

void func(char str[],int n)// str 是字符串,n是串长棚肢乎度

{

int i,j

i=0

for(i=0i<ni++)

{

j=0

while(str[j]!='\0')

{

data[i][j]=(int)(str[(j+i)%n]-0x30)

j++

}

}

}

void main()

{

char str[]="123"

/*也饥枯可以自己输入串并检测串长度,这只是个测试程序*/

int n=3

func(str,3)

for(int i=0i<ni++)

{

int j=0

while(j!=n)

{

cout<<data[i][j]<<' '

j++

}

cout<<endl

}

}

//物册---------------------------------------------------------------------------

#include <stdio.h>

#include <conio.h>罩则宏

#include <stdlib.h>

#include <time.h>

#define SP 32

#define ESC 27

int main(void)

{

int a,b,fg

char ch

srand(time(NULL))

do

{

a=rand()%9000+1000

b=rand()%9000+1000

fg=0

printf("%d+%d="盯正,a,b)

while (fg<3)

{

ch=getch()

if (ch==SP&&!fg) {

printf("%d\n",a+b)

fg=1

}

else if (ch==SP&&fg==1) {

system("cls")

break

}

else if (ch==ESC) {

break

}

}

}while (ch!=ESC)

return 0

}

//---------------------------------------------------------------------------


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

原文地址: https://outofmemory.cn/yw/12380511.html

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

发表评论

登录后才能评论

评论列表(0条)

保存