补全程序代码
int (*p1)(int a1,int b1),int (*p2)(int a2,int b2)
Ⅱ java 补全代码
楼主,依题意,完整的程序如下:
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Exam2 extends Thread implements ActionListener
{
//声明界面元素
private JFrame timeFrame;
private JButton startButton;
private JButton stopButton;
private JButton resetButton;
private JLabel timeLabel;
//定义变量存储时、分、秒
int hour = 0;
int minute = 0;
int second = 0;
//声明线程对象
Thread myThread;
public Exam2()
{
timeFrame = new JFrame("计时器");
startButton = new JButton("开始");
stopButton = new JButton("停止");
resetButton = new JButton("重置");
timeLabel = new JLabel("00:00:00");
timeFrame.setLayout(new FlowLayout());
timeFrame.setBounds((Toolkit.getDefaultToolkit().getScreenSize().width - 300)/2,
(Toolkit.getDefaultToolkit().getScreenSize().height - 200)/2, 300, 200);
timeFrame.add(timeLabel);
timeFrame.add(startButton);
timeFrame.add(stopButton);
timeFrame.add(resetButton);
timeFrame.setVisible(true);
timeFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
startButton.addActionListener(this);
stopButton.addActionListener(this);
resetButton.addActionListener(this);
myThread = this;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == this.startButton)
{
System.out.println("计时开始...");
if(this.start)
{
this.myThread.start();
}
else
{
this.start = true;
}
}
if(e.getSource() == this.stopButton)
{
System.out.println("计时停止...");
this.start = false;
}
if(e.getSource() == this.resetButton)
{
hour = 0;
minute = 0;
second = 0;
}
}
volatile boolean start = true;
@Override
public void run()
{
while(true)
{
if(this.start)
{
second++;
try
{
Thread.sleep(1000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
if(second >= 60)
{
second = 0;
minute++;
}
if(minute >= 60)
{
minute = 0;
hour++;
}
showTime();
}
}
}
private void showTime()
{
String strTime = "";
if(hour < 10)
{
strTime += "0"+hour + ":";
}
else
{
strTime += hour + ":";
}
if(minute < 10)
{
strTime += "0"+minute + ":";
}
else
{
strTime += minute + ":";
}
if(second < 10)
{
strTime += "0"+second;
}
else
{
strTime += second;
}
this.timeLabel.setText(strTime);
}
public static void main(String[] args)
{
new Exam2();
}
}
有问题欢迎提问,满意请点赞,谢谢!
Ⅲ 求补全程序
#include <stdio.h>
void main() {
int a[11]={19,17,15,13,11,9,7,5,3,1},k,i;
scanf("%d",&k);
for (i=9; i>=0; i--)
{
if (a[i]<k)
{
a[i+1]=a[i];
if (i==0)
a[i]=k ;
}
else
{
a[i+1]=k;
break;
}
}
for (i=0; i<11; i++)
printf("%d ",a[i]);
}
Ⅳ C语言 补全程序
Ⅳ C语言求救=。=帮忙补全程序
程序1代码:
/*
功能:产生20个[30,120]上的随机整数放入二维数组a[5][4]中,求每行元素的和
*/
#include<stdio.h>
voidwwjt();
voidrow_sum(inta[5][4],intb[5])
{
inti=0,j=0,sum=0;
for(i=0;i<5;i++)
{
sum=0;
for(j=0;j<4;j++)
{
sum+=a[i][j];
}
b[i]=sum;
}
}
main()
{
voidrow_sum();
inta[5][4],b[5],i,j;
for(i=0;i<5;i++)
for(j=0;j<4;j++)
a[i][j]=rand()%(120-30+1)+30;
FILE*fp=fopen("in.dat","w");//将随机产生的数组写入到in.dat中,供wwjt()函数使用
for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
printf("%5d",a[i][j]);
fprintf(fp,"%5d",a[i][j]);
}
printf(" ");
fprintf(fp," ");
}
fclose(fp);
row_sum(a,b);
for(i=0;i<5;i++)
printf("%6d",b[i]);
printf(" ");
wwjt();
}
voidwwjt()
{
FILE*IN,*OUT;
intm,n;
inti[5][4];
into[5];
IN=fopen("in.dat","r");
if(IN==NULL)
{
printf("ReadFILEError");
}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{
printf("WriteFILEError");
}
for(m=0;m<5;m++)
for(n=0;n<4;n++)
fscanf(IN,"%d",&i[m][n]);
row_sum(i,o);
for(n=0;n<5;n++)
fprintf(OUT,"%d ",o[n]);
fclose(IN);
fclose(OUT);
}
运行结果:
108 104 67 112
31 96 68 46
31 89 32 98
43 34 120 44
117 66 53 67
391 241 250 241 303
程序2代码:
/*
功能:实现两个整数的交换。
例如:给a和b分别输入:60和65,输出为:a=65b=60
*/
#include<stdio.h>
voidwwjt();
voidfun(int*a,int*b)
{
inttmp;
tmp=*a;
*a=*b;
*b=tmp;
}
main()
{
inta,b;
printf("Entera,b:");
scanf("%d%d",&a,&b);
fun(&a,&b);
printf("a=%db=%d ",a,b);
wwjt();
}
voidwwjt()
{
FILE*IN,*OUT;
inta,b,n;
IN=fopen("in.dat","r");
if(IN==NULL)
{
printf("ReadFILEError");
}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{
printf("WriteFILEError");
}
for(n=0;n<5;n++)
{
fscanf(IN,"%d%d",&a,&b);
fun(&a,&b);
fprintf(OUT,"a=%db=%d ",a,b);
}
fclose(IN);
fclose(OUT);
}
运行结果:
Enter a,b: 60 65
a=65 b=60
程序3代码:
/*
题目:编写函数,要求输入一行字符,统计其中字母、数字、空格及其他字符的个数
(用指针作为函数参数)。
*/
#include<stdio.h>
#defineN100
voidfun(charstr[],int*p1,int*p2,int*p3)
{
inti;
i=0;
while(str[i]!='